Python module-json

Source: Internet
Author: User

1.JSON (Javascript Object Notation) is a lightweight data interchange format. Easy for people to read and write. It is also easy for machine parsing and generation. It is based on JavaScript programming Language, Standard ECMA-262 a subset of 3rd Edition-december 1999. JSON takes a completely language-independent text format, but also uses a similar idiom to the C language family (c, C + +, C #, Java, JavaScript, Perl,python, etc.). These features make JSON an ideal data exchange language.

JSON is constructed in two structures: a combination of "name/value" pairs, which can be understood as objects (object), records (record), structures (structs), dictionaries (dictionary), hash tables (hash table), and keyed lists (keyed list) or an associative array (associative array). An ordered list of values: In most languages, is understood as an array (array). 2.python starts with JSON after 2.6 and can be Import JSONImport the JSON module.    The main object is serialization and deserialization. Encoding converts a Python object to a JSON string, and decoding converts the JSON format string to a Python object.
The JSON type corresponds to the Python primitive type as shown in the following table

Using the Json.dumps method, you can convert a Python object to a JSON object, and the Json.dumps method provides a number of useful parameters to choose from, compared with sort_keys (sorting Dict objects, we know that the default dict is unordered), Separators,indent and other parameters, the dumps method is defined as:

Dumps (obj, Skipkeys=false, Ensure_ascii=true, Check_circular=true,
Allow_nan=true, Cls=none, Indent=none, Separators=none,
Default=none, Sort_keys=false, **kw):
Json.load and Json.jump files need to be stored in JSON format for file reads and writes.
Json.loads and Json.jumps are operations on Python objects.



To be continued ************************************************* **************

Python module-json

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.