python demjson

这个是第三方的json库

首先安装

http://deron.meranda.us/python/demjson/

demjson-2.2.4.tar.gz

#tar -xzf demjson-2.2.4.tar.gz

# cd demjson-2.2.4

# python setup.py install

OK,试试看看

//test.py

1 import demjson

  2 data = [{'I':1, 'you':2}]

  3 _json = demjson.encode(data)

  4 print(type(_json), _json)

  5

  6 text = demjson.decode(_json)

  7 print(type(text), text)

//result

# python test.py
(<type 'unicode'>, u'[{"I":1,"you":2}]')
(<type 'list'>, [{u'I': 1, u'you': 2}])

原文地址:https://www.cnblogs.com/woodzcl/p/7852121.html