0

I have a json data which has another json data as its values. I want to change the value of a key. Key is given with separator dot(.)

import json    
data1='{"name":"xxx","info":{"mark":{"sub1":"11","sub2":22,"sub3":{"sub31":22,"sub32":44}}},"avg":33.33}'
data=json.loads(data1)
key="info.mark.sub3.sub32"
value=98

How can i change the value of the key without doing like this data["info"]["mark"]["sub3"]["sub32"]=value ?

Martijn Pieters
  • 1,048,767
  • 296
  • 4,058
  • 3,343
Dinoop Nair
  • 2,663
  • 6
  • 31
  • 51

0 Answers0