参考来源
一、导入库
import json
二、python对象 -> json串
1. 使用函数
json.dump
2. 参数列表
json.dump(obj, skipkeys = False, ensure_ascii = True, check_circular = True, allow_nan = True, cls = None, indent = None, separators = None, encoding = 'utf-8', default = None, sort_keys = False, **kw)
3. python数据类型向json类型的转换对照表
| python |
json |
| dict |
object |
| list、tuple |
array |
| str、unicode |
string |
| int、long、float |
number |
| True |
true |
| False |
false |
| None |
null |
三、json串 -> python对象
1. 使用函数
json.loads
2. 参数列表
json.loads(s[, encoding[, cls[, object_hook[, parse_float[, parse_int[, parse_constant[, object_pairs_hook[, **kw]]]]]]]])
3. json类型向python数据类型的转换对照表
| json |
python |
| object |
dict |
| array |
list |
| string |
unicode |
| number(int) |
int, long |
| number(real) |
float |
| true |
True |
| false |
False |
| null |
None |