from: https://blog.csdn.net/u011416077/article/details/49407047

使用demjson
encode
#!/usr/bin/python
import demjson

data = [ { 'a' : 1, 'b' : 2, 'c' : 3, 'd' : 4, 'e' : 5 } ]

json = demjson.encode(data)
print json

运行输出
[{"a":1,"b":2,"c":3,"d":4,"e":5}]


decode
#!/usr/bin/python
import demjson

json = '{"a":1,"b":2,"c":3,"d":4,"e":5}';

text = demjson.decode(json)
print text

运行输出
{u'a': 1, u'c': 3, u'b': 2, u'e': 5, u'd': 4}


————————————————
版权声明:本文为CSDN博主「Gemini_Dong」的原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/u011416077/article/details/49407047

相关文章:

  • 2022-01-05
  • 2022-12-23
  • 2021-08-10
  • 2021-11-24
  • 2021-06-30
  • 2022-12-23
  • 2021-10-13
猜你喜欢
  • 2022-01-11
  • 2021-06-20
  • 2021-06-23
  • 2022-01-21
  • 2022-12-23
  • 2022-12-23
  • 2021-12-20
相关资源
相似解决方案