The original JSON file:
{
"data": {
"count_at_hub": [
{
"hub": "A",
"date": "",
"size": "1",
"count": 141
},
{
"hub": "A",
"date": "",
"size": "2",
"count": 44
},
{
"hub": "A",
"date": "",
"size": "3",
"count": 3
},
{
"hub": "A",
"date": "",
"size": "0",
"count": 1446
},
{
"hub": "B",
"date": "",
"size": "1",
"count": 202
},
{
"hub": "B",
"date": "",
"size": "0",
"count": 2082
},
{
"hub": "B",
"date": "",
"size": "3",
"count": 11
},
{
"hub": "B",
"date": "",
"size": "2",
"count": 53
}
],
"Part B":[
{
}
]
},
"success": true,
"errors": [],
"e": {}}
I want to change the structure to:
{
"data": {
"count_at_hub": [
{
"hub": "A",
"date": "",
"size1": 141,
"size2": 44,
"size3": 3,
"size4": 1446
},
{
"hub": "B",
"date": "",
"size1": 202,
"size2": 2082,
"size3": 11,
"count": 53
}
],
"Part B":[
{
}
]
},
"success": true,
"errors": [],
"e": {}}
Basically, I want to put all the count of the same hub under the same array. How do I come about doing this?
In terms of huge amount of data, will changing the JSON to the new file make the loading speed longer as compared to making JS looping through the original file to build a dashboard?
size1, size2, size3, ...instead of an array?size1, size2 to size4. They will contain the count. Do you have any better suggestion as to which data structure will be the best? Thanks!sizesarray with size1 value @ sizes[0], size2 value @ sizes[1] etc... would be better i suppose. I will prepare an answer accordingly.