- Subscribe to RSS Feed
- Mark Question as New
- Mark Question as Read
- Float this Question for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page
NiFi Jolttransform to package json array into object?
- Labels:
-
Apache NiFi
Created 05-02-2019 07:36 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
i have json array like the following: [{"id":"one"}, {"id,"two"}] Any idea how could i "package" it into json "root" like the following: { [{"id":"one"}, {"id,"two"}] }
I am trying to use JolttransformJSON but couldn't find any clues how to approach operation like this....
Thank you
Created 05-02-2019 08:51 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I don't think your desired output is valid JSON, as the root object only has an array in it, not a key/value pair. If you want a key in there (let's call it root) the following spec will work in JoltTransformJSON:
[ { "operation": "shift", "spec": { "*": "root.[]" } } ]
Otherwise if you just want to add braces around the array, you can use ReplaceText, replacing the entire thing with {$1}
Created 05-02-2019 08:51 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I don't think your desired output is valid JSON, as the root object only has an array in it, not a key/value pair. If you want a key in there (let's call it root) the following spec will work in JoltTransformJSON:
[ { "operation": "shift", "spec": { "*": "root.[]" } } ]
Otherwise if you just want to add braces around the array, you can use ReplaceText, replacing the entire thing with {$1}
Created 05-03-2019 04:23 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
how can i transform array of maps into array of values: ["one", "two", "three"] ?
