A description of the JSON module for Python

Source: Internet
Author: User

This article describes the JSON module description for Python

Introduction

For Web developers, JSON text must be familiar and skilled to use. Most Web site API calls return data, which is in JSON format. If you look at what the JSON object contains, it's came David to be able to match the JSON data type with the Python data type.

So what's the use of Python's standard module package JSON? Why should I use the format of JSON to format python? Why can't I use JSON-formatted data directly? Is it almost the same type and corresponding?

In fact, after looking at the data structure carefully, it can be seen that there are subtle differences between the original JSON format and several Python data types. Here, you first list the corresponding formats that are converted 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 common 4 functions
' Dump '
' Dumps '
' Load '
' Loads '

Where ' dump ' is paired with ' load ', it is mainly used for large data situations. ' Dumps ' and ' loads ' apply to cases where the string or data is small. The main is the former converted to write the file to save, the latter conversion finished directly loaded in memory.

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.