更多的信息,可以參考python內(nèi)部的json文檔:
python>>> help(json)
或者官方文檔: http://docs.python.org/library/json.html#module-json.
下面給出一個(gè)使用python解析json的簡單例子:
#Note:
#1.Also, if you write json script from python,
#you should use dump instead of load. pleaser refer to "help(json)".
#json file:
#The file content of temp.json is:
#{
# "name":"00_sample_case1",
# "description":"an example."
#}
#f = file("temp.json");
#s = json.load(f)
#print s
#f.close
#json string:
s = json.loads('{"name":"test", "type":{"name":"seq", "parameter":["1", "2"]}}')
print s
print s.keys()
print s["name"]
print s["type"]["name"]
print s["type"]["parameter"][1]
PS:關(guān)于json操作,這里再為大家推薦幾款比較實(shí)用的json在線工具供大家參考使用:
在線JSON代碼檢驗(yàn)、檢驗(yàn)、美化、格式化工具:
http://tools.VeVB.COm/code/json
JSON在線格式化工具:
http://tools.VeVB.COm/code/jsonformat
在線XML/JSON互相轉(zhuǎn)換工具:
http://tools.VeVB.COm/code/xmljson
json代碼在線格式化/美化/壓縮/編輯/轉(zhuǎn)換工具:
http://tools.VeVB.COm/code/jsoncodeformat
在線json壓縮/轉(zhuǎn)義工具:
http://tools.VeVB.COm/code/json_yasuo_trans
C語言風(fēng)格/HTML/CSS/json代碼格式化美化工具:
http://tools.VeVB.COm/code/ccode_html_css_json
新聞熱點(diǎn)
疑難解答
圖片精選