Python json module description

Source: Internet
Author: User
Tags package json
This article introduces the Python json module description

This article introduces the Python json module description

Introduction

For web developers, json text must be well-known and used. The data returned by API calls of most websites is in json format. If you look at the content contained in the json object, I believe that people familiar with Python will soon be able to map the json data type to the Python data type.

So what is the use of Python's standard module package json? Why should I convert the json format to the corresponding Python format? Why can't I use json data directly? Isn't it of almost the same type and corresponding?

In fact, after looking at the data structure carefully, we can still see that there are still slight differences between the original json format and several data types in Python. Here, we will first list the corresponding formats for mutual conversion between the two:

Python       ==>    jsondict                objectlist, tuple         arraystr, unicode        stringint, long, float    numberTrue                trueFalse               falseNone                nulljson        ==>     Pythonobject              dictarray               liststring              unicodenumber(int)         int, longnumber(real)        floattrue                Truefalse               False

Json commonly used four functions
'Dump'
'Dumps'
'Load'
'Loads'

Specifically, 'dump' and 'load' are used in combination, which is mainly suitable for large data volumes. 'Dumps' and 'loads 'are applicable when strings or data are small. The former is converted to the written file for storage, and the latter is directly loaded into the memory after conversion.

The above is a detailed description of the Python json module. For more information, see other related articles in the first PHP community!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.