I want to combine duplicate key and value pairs in JSON dictionaries. I am having trouble doing that. As other keys are not the same and are repetitive. I have the following JSON format:
[
{
"date":"2018-12-01",
"9":{
"mean":{
"x_axis":-0.71,
"y_axis":8.75,
"z_axis":5.23
}
}
},
{
"date":"2018-12-02",
"4":{
"mean":{
"x_axis":-0.76,
"y_axis":7.83,
"z_axis":2.63
}
}
},
{
"date":"2018-12-02",
"5":{
"mean":{
"x_axis":0.59,
"y_axis":6.46,
"z_axis":7.12
}
}
},
{
"date":"2018-12-02",
"10":{
"mean":{
"x_axis":1.07,
"y_axis":9.46,
"z_axis":0.08
}
}
}
]
But I want the following JSON format:
[
{
"date":"2018-11-22",
"1":{
"mean":{
"x_axis":3.11,
"y_axis":3.22,
"z_axis":3.33
}
},
"2":{
"mean":{
"x_axis":2.11,
"y_axis":2.22,
"z_axis":2.33
}
}
},
{
"date":"2018-11-23",
"1":{
"mean":{
"x_axis":3.11,
"y_axis":3.22,
"z_axis":3.33
}
},
"2":{
"mean":{
"x_axis":2.11,
"y_axis":2.22,
"z_axis":2.33
}
}
}
]
See that the same date key and values do not repeat. If the date is the same all other keys are under it. Please help!