I'm trying to create a single json output based on a nested Json:
{
"Id" : "1",
"items" : [
{"item_name" : "shirt","value" : 10},
{"item_name" : "dress","value" : 20},
{"item_name" : "ice cream","value" : 30}
]
}
My expected output would be:
[
{
"id": "1",
"item_name": "shirt",
"value": 10,
"index_position": 0
},
{
"id": "1",
"item_name": "dress",
"value": 20,
"index_position": 1
},
{
"id": "1",
"item_name": "ice cream",
"value": 30,
"index_position": 2
}
]
The only output that I was able to fetch is on this snippet:
https://jqplay.org/s/G6mYAI47LE
What would be the best way to iterate over an inner array and at the same time fetch the outer object data?