ubuntu下安装,再次祭起apt-get大法:
sudo apt-get install python-json
如果是在其它系统,需要到:http://pypi.python.org/pypi/python-json下载。
需要注意的是http://docs.python.org/library/json.html文档已经没有作用。
新的用法:
>>> data = json.read(‘{“houseNumber”:”742″,”street”:”Evergreen Terrace”,”city”:”Springfield”,”postcode”:”49007″,”country”:”USA”,”comments”:[“Deliveries accepted.”,”Familiar address, huh?”,””]}’)
>>> data[‘city’]
‘Springfield’
反向:
>>> test = json.write(data)
>>> test
‘{“city”:”Springfield”,”country”:”USA”,”comments”:[“Deliveries accepted.”,”Familiar address, huh?”,””],”street”:”Evergreen Terrace”,”postcode”:”49007″,”houseNumber”:”742″}’
json支持的语言真多啊。每种语言还不是只有一种实现。
参考资料:
1. python + django + 淘宝API 应用一例
2.JSON Demo
3.JSON主站