I receive JSON from API:
[
{
"date":"2023-08-15",
"params":[
{
"id":"3877",
"available":true,
"tag": "podxmeil"
},
{
"id":"559",
"available":false,
"tag": "kogdaeymtim"
}
]
},
{
"date":"2023-08-16",
"params":[
{
"id":"327",
"available":false,
"tag": "syuopernuitd"
},
{
"id":"916",
"available":false,
"tag": "tabgramidi"
}
]
}
]
I want to loop through params
array and add values from it to top level
Tried with:
[
{
"operation": "shift",
"spec": {
"*": {
"date": "[&1].date",
"params": {
"*": {
"id": "[&1].id",
"available": "[&1].available"
}
}
}
}
}
]
But it stores values inside array and returns invalid result:
I Expect this result:
You can use the following spec.
[
{
"operation": "shift",
"spec": {
"*": {
"params": {
"*": {
"@(2,date)": "&3.&1.date",
"id": "&3.&1.&",
"available": "&3.&1.&"
}
}
}
}
},
{
"operation": "shift",
"spec": {
"*": {
"*": ""
}
}
}
]