Solved
Make flat json array from nested one via JOLT
Hi everyone!
I'm trying to flat array and it view as simple case, but I can't reach the goal.
Here is simple json input:
{
"MainArray": {
"mattr1": "some_value1",
"mattr2": "some_value2",
"Subarray": {
"sattr1": 1,
"sattr2": 2,
"sattr3": 3
}
}
}Then I would like to convert it to array of arrays [key, value],
Here is Desired Output:
{
"ResultArray" : [
[ "mattr1", "some_value1" ],
[ "mattr2", "some_value2" ],
[ "sattr1", 1 ],
[ "sattr2", 2 ],
[ "sattr1", 3 ]
]
}Here is my spec:
[
{
"operation": "shift",
"spec": {
"MainArray": {
"*": {
"$": "ResultArray[#2][0]",
"@": "ResultArray[#2][1]"
},
"Subarray": {
"*": {
"$": "ResultArray[#3][#2][0]",
"@": "ResultArray[#3][#2][1]"
}
}
}
}
}
]And I don't understand how to fix problem when Subarrays is inside extra array in my result:
{
"ResultArray" : [
[ "mattr1", "some_value1" ],
[ "mattr2", "some_value2" ],
[
[ "sattr1", 1 ],
[ "sattr2", 2 ],
[ "sattr3", 3 ]
]
]
}Any advise, please.

