I am new to Python and I am playing with JSON data. I would like to dynamically build a JSON object by adding some key-value to an existing JSON object.
I tried the following but I get TypeError: 'str' object does not support item assignment
:
import json
json_data = json.dumps({})
json_data["key"] = "value"
print 'JSON: ', json_data
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…