kmiesse
8 years agoContributor
Add index of element in array to the element
How do I add the index of the element in an array to the element? I have the following doc that I simply want to add the index of the element in the array1 array to each element in the array1 array:
{
“field1”: “46”,
“array1”: [
{
“number”: 1,
“code”: “TSD”
},
{
“number”: 11,
“code”: “NONE”
}
]
}
Desired result:
{
“field1”: “46”,
“array1”: [
{
“number”: 1,
“code”: “TSD”,
“index”: 0
},
{
“number”: 11,
“code”: “NONE”,
“index”: 1
}
]
}