Json Dictionary

基本形


import json
data={
	"name":"Alice",
	"age":30,
	"children":[
		{"name":"Bob", "age":5},
		{"name":"Charlie", "age":3}
	],
	"married": True,
	"pets": None
}

json_string=json.dumps(data,indent=4)
print(json_string)
  

追加


import json
data={
}

data["name"] = "Alice"
key="age"
value=32
data[key]=value

data["children"]=[{"name":"Bob","age":5},{"name":"Charlie","age":3}]

json_string=json.dumps(data,indent=4)
print(json_string)