If I have an array of objects like this:
[
{
"remote" : [
{
"id" : 1
},
{
"id" : 2
},
{
" id" : 3
}
],
"text_id" : 1
},
{
"remote" : [
{
"id" : 4
},
{
"id" : 5
},
{
"id" : 6
}
],
"text_id" : 2
}
]
How would you add "text_id" field to every object inside .[].remote[] array so it would become
[
{
"remote" : [
{
"id" : 1,
"text_id" : 1
},
{
"id" : 2,
"text_id" : 1
},
{
" id" : 3,
"text_id" : 1
}
]
},
{
"remote" : [
{
"id" : 4,
"text_id" : 2
},
{
"id" : 5,
"text_id" : 2
},
{
"id" : 6,
"text_id" : 2
}
]
}
]
I have already spent several hours trying to figure this out. It looks like there has to be a way to do this using foreach directive, but after I checked the manual for it, it seemed to me pretty obscure so I though maybe someone could give an example. Thanks.