For each array object, get the id and assign it as a key to the array object.
I am trying to use the JOLT processor in NIFI.
Any help would be much appreciated!
Input:
{
"list": [
{
"catalog": {
"id": "0981",
"Desc": "Chess toy"
},
"quantity": 10,
"price": 10.5
},
{
"catalog": {
"id": "01234",
"Desc": "Water bottle"
},
"quantity": 5,
"price": 5.4
}
]
}
Expected output:
{
"list": [
{
"0981": {
"catalog": {
"id": "0981",
"Desc": "Chess toy"
},
"quantity": 10,
"price": 10.5
},
"01234": {
"catalog": {
"id": "01234",
"Desc": "Water bottle"
},
"quantity": 5,
"price": 5.4
}
}
]
}
2
Answers
You can use this shift transformation spec
where keys come from the identifier
@1,id
,&3
represents going tree three levels up to get the literallist
and[#4]
will bring them in array type manner.The following will do it all dynamically
You can use this spec: