I have this JSON :
{
"duration": 1942,
"frame_id": 0,
"detect1": [
{
"type": {
"s_type1": [
{
"confidence": 98.70016,
"klass": -1,
"name": "c*****"
},
{
"confidence": 1.042385,
"klass": -1,
"name": "c*****"
},
{
"confidence": 0.1587732,
"klass": -1,
"name": "s*****"
}
],
"s_type2": [
{
"confidence": 92.82484,
"klass": -1,
"name": "b*****"
},
{
"confidence": 7.098834,
"klass": -1,
"name": "b*****"
},
{
"confidence": 0.02423214,
"klass": -1,
"name": "p*****"
},
],
"Box": [
80.80994,
170.0965,
1091.778
]
},
"confidences": [
90.08681,
99.91595,
90.12489
]
}
]
}
And i would like to save some of key and values from this JSON to another JSON. The new JSON will keep :
duration
(k,v),frame_id
(k,v),detect1
:type
:s_type1
ands_type2
only the first dict will be keped and theklass
(k,v) will be removed,Box
(k,v)
confidences
(k,v)
The final result :
{
"duration": 1942,
"frame_id": 0,
"detect1": [
{
"type": {
"s_type1": [
{
"confidence": 98.70016,
"name": "c*****"
},
],
"s_type2": [
{
"confidence": 92.82484,
"name": "b*****"
}
],
"Box": [
80.80994,
170.0965,
1091.778
]
},
"confidences": [
90.08681,
99.91595,
90.12489
]
}
]
}
I was trying to do it with the JMESPath library but I can't get a good result.
Have someone any idea to do this ?
Thanks