官网
https://www.json.org/json-en.html
json类型
Python | JSON |
---|---|
dict | object |
list,tuple | array |
str | string |
int, float | number |
True | true |
False | false |
None | null |
import json
dic = {'a': 1, 'b': 2}
dic_json = json.dumps(dic) # {"a": 1, "b": 2}
dic = json.loads(dic_json) # {'a': 1, 'b': 2}
dic_json = json.dumps(['foo', {'bar': ('baz', None, 1.0, 2)}]) # ["foo", {"bar": ["baz", null, 1.0, 2]}]
dic = json.loads(dic_json) # ['foo', {'bar': ['baz', None, 1.0, 2]}]