Python library has simplejson in json and json two of them simplejson updated more frequently speed, speed in the case of C libraries much faster, json library after Python 2.6 has been built can be referenced directly.
A transcoding introduced Practice:
try:
import simplejson as json
except ImportError:
import json
simplejson和json的性能:For dumping, json is faster than simplejson. For loading, simplejson is faster.
json a lightweight data interchange format, wherein, the python json.dumps json string into object coded, decoded string json.loads the Python object json
python original type of the conversion table json type:
Python | JSON |
dict {u'a': 1, u'c': 3, u'b': 2, u'e': 5, u'd': 4} | object '{"a":1,"b":2,"c":3,"d":4,"e":5}' |
list, tuple [ { 'a' : 1, 'b' : 2, 'c' : 3, 'd' : 4, 'e' : 5 } ] | array [{"a": 1, "c": 3, "b": 2, "e": 5, "d": 4}] |
str , unicode | string |
int, long, float | number |
True | true |
False | false |
None | null |