- Subscribe to RSS Feed
- Mark Question as New
- Mark Question as Read
- Float this Question for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page
Jolt transform use keys as value
- Labels:
-
Apache NiFi
Created 01-11-2023 07:58 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello, I cannot find an answer on the www to my following question. I have tried splitjson and jolttransform to achieve my desired outcome, but nothing does the trick. My input file looks like this:
{
"BVjsoBHDSI" : {
"date" : "2021-04-08",
"description" : "blabla1",
"number" : 40
},
"FudNSk" : {
"date" : "2021-09-26",
"description" : "blabla2",
"number" : 80
},
"Cfjdsl54fd" : {
"date" : "2022-05-10",
"description" : "blablubb",
"number" : 31
}
}
Actually I just want to split the stupid thing, but since the root level has a different individual value nifi doesn't understand what I want to do. The idea was to use a jolt transform to add a key "id" with the original key as value. I can't figure out a proper specification though. Glad to hear your ideas.
Desired output:
{
"BVjsoBHDSI" : {
"date" : "2021-04-08",
"description" : "blabla1",
"number" : 40,
"id" : "BVjsoBHDSI"
},
"FudNSk" : {
"date" : "2021-09-26",
"description" : "blabla2",
"number" : 80,
"id" : "FudNSk"
},
"Cfjdsl54fd" : {
"date" : "2022-05-10",
"description" : "blablubb",
"number" : 31,
"id" : "Cfjdsl54fd"
}
}
Then I could easily overwrite the root and split the flowfile as usual.
Created 01-12-2023 03:44 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Idk if it is much of a help, but you can try checking the Jolt Transform quick reference
There's this link to test JOLT specifications.
You can try starting with something like
[{
"operation": "shift",
"spec": {
"*": "&"
}
}, {
"operation": "default",
"spec": {
"*": {
"id": "&(1,0)"
}
}
}]
