For more information, refer to the json document in python:
Python >>> help (json)
Or official document: http://docs.python.org/library/json.html#module-json.
The following is a simple example of using python to parse json:
Copy codeThe Code is 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 shoshould 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]