I have JSON data coming thru external application A where which need to be sent to application B . And before the data goes to application B, all the attributes in the json need to be renamed.
for example , incoming json data structure is -
{
"Array1": [
{
"field1": "foo1",
"field2": [
"bar1",
"bar2"
]
},
{
"field1": "foo2",
"field2": [
"bar3",
"bar4"
],
...
{
"field1": "fooN",
"field2": [
"barX",
"barY"
]
}
]
}
Where number of elements in Array1
are variable per record.
The expected output is -
{
"ElementList": [
{
"Attr1": "foo1",
"Attr2": [
"bar1",
"bar2"
]
},
{
"Attr1": "foo2",
"Attr2": [
"bar3",
"bar4"
],
...
{
"Attr1": "fooN",
"Attr2": [
"barX",
"barY"
]
}
]
}
Basically
- Array1 renamed to ElementList
- each Field1 in Array1 renamed to Attr1
- each Field2 Array1 renamed to Attr2
For simple rename, I can use shift
operator but I am not able to specify correct jolt transformation for arrays. Any ideas?