I'm trying to use nifi jolttransformjson to transform my JSON. I'm playing around using this site http://jolt-demo.appspot.com/#modify-stringFunctions
I have a JSON
{
"response": {
"Attribute": [
{
"id": "670868",
"another_id": "8385",
"category": "A",
"type": "abc"
},
{
"id": "670870",
"another_id": "8385",
"category": "B",
"type": "abc"
}
]
}
}
My Jolt Spec is
enter code here
[
{
"operation": "shift",
"spec": {
"response": {
"Attribute": {
"*": {
"type": "TYPE",
"category": "CATEGORY"
}
}
}
}
}
]
Current Output is
{
"TYPE" : [ "abc", "abc" ],
"CATEGORY" : [ "A", "B" ]
}
Wanted output is
[
{
"TYPE":"abc",
"CATEGORY":"A"
},
{
"TYPE":"abc",
"CATEGORY":"B"
}
]
Help please. I tried so many combinations and I can't seem to figure this out.
See Map to List
example and you will find out solution:
[
{
"operation": "shift",
"spec": {
"response": {
"Attribute": {
"*": {
"@type": "[#2].TYPE",
"@category": "[#2].CATEGORY"
}
}
}
}
}
]