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

Tomorin
Release: 2018-08-17 14:44:59
Original
21850 people have browsed it

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]]]]]]]])
Copy after login

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
Copy after login

The execution result of the above code is:

{u'a': 1, u'c': 3, u'b': 2, u'e': 5, u'd': 4}
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template