python json

来源:互联网 发布:淘宝企业店铺出售过程 编辑:程序博客网 时间:2024/04/28 12:38

转自 http://blog.chinaunix.net/uid-9525959-id-3074355.html


#!/usr/bin/pythonimport json#Function:Analyze json script#Json is a script can descript data structure as xml, #for detail, please refer to "http://json.org/json-zh.html".#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 sprint s.keys()print s["name"]print s["type"]["name"]print s["type"]["parameter"][1]


0 0