I am trying to change the JSON format using python. The received message has some key-value pairs and needs to change certain key names before forwarding the message. for normal key-value pairs, I have used "data. pop" method, data["newkey"]=data.pop("oldkey") . But it got complicated with nested key-values. This is just a part of big file that needs to be convrted. How to convert this
{
"atrk1": "form_varient",
"atrv1": "red_top",
"atrt1": "string",
"atrk2": "ref",
"atrv2": "XPOWJRICW993LKJD",
"atrt2": "string"
}
into this?
"attributes": {
"form_varient": {
"value": "red_top",
"type": "string"
},
"ref": {
"value": "XPOWJRICW993LKJD",
"type": "string"
}
}