I have the following JSON sample:
[
{
"id": "116621",
"field": "list18",
"line": 0,
"value": "6",
"changeOrder": 5
},
{
"id": "116621",
"field": "list16",
"line": 0,
"value": "47",
"changeOrder": 4
},
{
"id": "116621",
"field": "list17",
"line": 0,
"value": "3",
"changeOrder": 2
},
{
"id": "116622",
"field": "list16",
"line": 1,
"value": "6",
"changeOrder": 3
},
{
"id": "116623",
"field": "list18",
"line": 2,
"value": "11",
"changeOrder": 6
},
{
"id": "116623",
"field": "list16",
"line": 2,
"value": "5",
"changeOrder": 1
}
]
I am trying to run a process that opens a record (based off the id), update values and then saves it.
However instead of running through each item and duplicating open the same record, it would save time by opening the same id record once, running through each item, and then saving it.
So what i need to do is to return the data like this so that it only opens the record once to update. For instance if it is id "116621" then it would group all the id "116621" so i can update each value that is returned - like this:
[
{
"id": "116621",
"field": "list18",
"line": 0,
"value": "6",
"changeOrder": 5
},
{
"id": "116621",
"field": "list16",
"line": 0,
"value": "47",
"changeOrder": 4
},
{
"id": "116621",
"field": "list17",
"line": 0,
"value": "3",
"changeOrder": 2
}
]
I wont know how many are in the array, nor what ID's they will be. All i know is that it will be a sorted array as I have already coded that bit in.
Any help to get a function to return the single array would really be helpful.
Thank you