I have a json object like this:
{
"sample1": {
"4": 2245,
"5": 2175,
"6": 3495,
"7": 1845,
...
"11.5": 1674,
"12.5": 1649
},
"sample2": {
"4": 3295,
"5": 3600,
"8": 2625,
"9": 2830,
...
"11.5": 2879,
"12.5": 3090
}
}
and I want to format this to:
[
{
"index": "4",
"sample1": "2245",
"sample2": "3295"
},
{
"index": "5",
"sample1": "2175",
"sample2": "3600"
},
{
"index": "6",
"sample1": "3495",
"sample2": ""
},
....
{
"index": "12.5",
"sample1": "1649",
"sample2": "3090"
}
]
In python it's very easy to do this using pandas, but I don't want to add python script into javascript. Any simple way to do this using javascript?
{ index: "7", ... }(which is present only in sample 1) and{ index: "11.5", ... }(which is present in both samples) but does contain{ index: "6", ... }(which is present only in sample 1)?...in the output which indicates etc. and added the last item in the array."sample2": ""for"index": "6". Yes, it would've been better if they had been explicit about it.