Home  >  Article  >  Backend Development  >  What does json.loads do? Briefly explain the usage of json.loads python

What does json.loads do? Briefly explain the usage of json.loads python

Tomorin
TomorinOriginal
2018-08-17 14:44:5921860browse

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:

What does json.loads do? Briefly explain the usage of json.loads python

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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn