Solved
Jolt- rearrange elements
Hello,
I am using jolt to change the structure of a payload to another form, and it must be dynamic, especially the top level elements "test" which can be multiple. I have tried but not getting it. I would appreciate your kind help.
Here is my input json:
{
"test1": "test output",
"test2": "test output",
"Details": {
"0": {
"id": "first",
"name": "the first one"
},
"1": {
"id": "second",
"name": "the second one"
}
}
}
and my output json is :
{
"Details" : [ {
"test1" : "test output",
"test2" : "test output",
"id" : "first",
"name" : "the first one"
}, {
"test1" : "test output",
"test2" : "test output",
"id" : "second",
"name" : "the second one"
} ]
}
my current jolt spec is:
[
{
"operation": "shift",
"spec": {
"Details": "Details",
"*": "outer.&"
}
},
{
"operation": "shift",
"spec": {
"Details": {
"*": {
"*": "Details[&1].&",
"@(2,outer)": "Details[&1].outer"
}
}
}
},
{
"operation": "shift",
"spec": {
"Details": {
"*": {
"outer": {
"*": "Details[&2].&"
},
"*": "Details[&1].&"
}
}
}
}
]
But I am not getting the desired output json as above.

