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
  • 963,270
  • 265
  • 3,804
  • 3,187
Dinoop Nair
  • 2,483
  • 6
  • 28
  • 50

0 Answers0