官网

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
  1. import json
  2. dic = {'a': 1, 'b': 2}
  3. dic_json = json.dumps(dic) # {"a": 1, "b": 2}
  4. dic = json.loads(dic_json) # {'a': 1, 'b': 2}
  5. dic_json = json.dumps(['foo', {'bar': ('baz', None, 1.0, 2)}]) # ["foo", {"bar": ["baz", null, 1.0, 2]}]
  6. dic = json.loads(dic_json) # ['foo', {'bar': ['baz', None, 1.0, 2]}]