For more information, refer to the JSON documentation within Python:
Python>>> Help (JSON)
or Official document: Http://docs.python.org/library/json.html#module-json.
Here's a simple example of using Python to parse JSON:
Copy Code code as follows:
#!/usr/bin/python
Import 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 S
Print S.keys ()
Print s["Name"
Print s[' type ' [' Name ']
Print s["type" ["parameter"][1]
PS: About JSON operation, here we recommend a few more practical JSON online tools for your reference to use:
Online JSON code inspection, inspection, landscaping, formatting tools:
Http://tools.jb51.net/code/json
JSON Online formatting tool:
Http://tools.jb51.net/code/jsonformat
Online Xml/json Mutual Conversion tool:
Http://tools.jb51.net/code/xmljson
JSON code online Format/beautify/compress/edit/Convert tools:
Http://tools.jb51.net/code/jsoncodeformat
Online JSON compression/escape tool:
Http://tools.jb51.net/code/json_yasuo_trans
C Language Style/html/css/json code formatting landscaping Tools:
Http://tools.jb51.net/code/ccode_html_css_json