China Naming Network - Ziwei Dou Shu - Python json quick parsing command
Python json quick parsing command
Json.dumps is used to encode Python objects into Json strings.
Json.loads is used to decode Json data. This function returns the data type of Python field.
The demjson.encode () function is used to encode Python objects into json strings.
The function decodes json data. This function returns the data type of Python field.
1. The following example encodes an array as data in JSON format:
#! /usr/bin/python
Import json
data = [ { 'a' : 1,' b' : 2,' c' : 3,' d' : 4,' e' : 5 } ]
json = json.dumps(data)
Print json
2. The following example shows how Python decodes JSON objects:
#! /usr/bin/python
Import json
jsonData = '{"a": 1," b":2," c":3," d":4," e ":5 } ';
text = json.loads(jsonData)
Print text