In this chapter we will introduce how to use Python language to encode and decode JSON objects. JSON(JavaScript Object Notation) is a lightweight data exchange format that is easy for humans to read and write
json.loads is used to decode JSON data. This function returns the data type of the Python field
Syntax
json.loads(s[, encoding[, cls[, object_hook[, parse_float[, parse_int[, parse_constant [, object_pairs_hook[, **kw]]]]]]]])
Instance
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
The execution result of the above code is:
{u'a': 1, u'c': 3, u'b': 2, u'e': 5, u'd': 4}
Json type conversion to python type control surface:
The above is the detailed content of What does json.loads do? Briefly explain the usage of json.loads python. For more information, please follow other related articles on the PHP Chinese website!