I have a requirement to add multiple properties to an array object based on one of the key value of the same array object.
My Input array is below
{
"body": [
{
"Base64Parts": ["Rick"],
"NoofParts": 1
},
{
"Base64Parts": ["John","Mark","Roy"],
"NoofParts": 3
},
{
"Base64Parts": ["Adam","Steve"],
"NoofParts": 2
}
]
}
Now based on the maximum value of the "NoofParts" key in the object, I would like to add the same number of properties to each object in the array. Here is my output object.
{
"body": [
{
"Base64Parts": ["Rick"],
"NoofParts": 1,
"Part1": "Rick",
"Part2": "",
"Part3": "",
},
{
"Base64Parts": ["John","Mark","Roy"],
"NoofParts": 3,
"Part1": "John",
"Part2": "Mark",
"Part3": "Roy",
},
{
"Base64Parts": ["Adam","Steve"],
"NoofParts": 2,
"Part1": "Adam",
"Part2": "Steve",
"Part3": "",
}
]
}
Please advise. I am looking out for ways without using nested apply to each.
Thanks and Regards,
Ramesh Mukka