import json
json.dumps | 将 Python数据类型转换成 JSON 数据类型 |
json.loads | 将 JSON 数据类型转换为 Python 数据类型 |
python 类型转换为 json 类型:
Python | JSON |
---|---|
dict | object |
list, tuple | array |
str, unicode | string |
int, long, float | number |
True | true |
False | false |
None | null |
json 类型转换为python 类型:
JSON | Python |
---|---|
object | dict |
array | list |
string | unicode |
number (int) | int, long |
number (real) | float |
true | True |
false | False |
null | None |