I'm trying to get a certain structure for my JSON but I'm struggling in the process and get an infinite loop.
I managed to get to a certain point with the original file by using the reduce() method, but I'm stuck with the last step.
here is the JSON:
{
"someNumbers_like_15269": {
"someNumbers_like_35896": [{
"TestPoint": "A",
"ItemNo": "12110",
"TestDesc": "Penalty Points"
}, {
"TestPoint": "A",
"ItemNo": "12110",
"TestDesc": "Brix"
}, {
"TestPoint": "B",
"ItemNo": "12110",
"TestDesc": "Texture"
}, {
"TestPoint": "B",
"ItemNo": "12110",
"TestDesc": "Viscosity"
}, {
"TestPoint": "C",
"ItemNo": "12110",
"TestDesc": "PH"
}, {
"TestPoint": "C",
"ItemNo": "12110",
"TestDesc": "Taste"
}]
}
}
And the desired result
{
"someNumbers_like_15269": {
"someNumbers_like_35896": {
"ItemNo": "12110",
"someOtherThing": "blabla",
"Test": [{
"TestPoint": "A",
"TestDesc": ["Penalty Points", "Brix"]
}, {
"TestPoint": "B",
"TestDesc": ["Texture", "Viscosity"]
}, {
"TestPoint": "C",
"TestDesc": ["PH", "Taste"]
}]
}
}
} PS: There will be multiple CC and multiple Batches, the JSON as more than 85 thousand lines
**
my original attempt can be found in here
**