That was quick and awesome, many thanks !! this gives an idea for all such type of transformations.
can you also suggest a solution for a case like below,
where the number of elements to be mapped subsection of the array does not matches the count of source array.
For the same input as above, below is expected output.
[
{
"REFILL":{
"item":[
{
"ITEM":"1",
"TEXT":"first",
"NAME":"laptop",
"WORK":"office"
},
{
"ITEM":"2",
"TEXT":"second",
"NAME":"mobile",
"WORK":"marketing"
}
]
}
},
{
"TOTLITEM":{
"item":[
{
"ITEM":"1",
"TEXT":"first",
"NAME":"none",
"DETAILS":[
{
"LINE":"1",
"WORK":"office"
},
{
"LINE":"2",
"WORK":"office"
}
]
},
{
"ITEM":"2",
"TEXT":"second",
"NAME":"none",
"DETAILS":[
{
"LINE":"1",
"WORK":"marketing"
}
]
}
]
}
}
]
being able to do this, will help a lot to handle any transformation thereafter. let me know the solution.