JSON overview and Python-related actions on JSON <转>

Source: Internet
Author: User

What is JSON:

JSON (JavaScript Object notation) is a lightweight data interchange format. Easy for people to read and write. It is also easy to machine parse and generate. It is based on JavaScript programming Language, Standard ECMA-262 a subset of 3rd Edition-december 1999. JSON uses a completely language-independent text format, but it also uses a family of C-language (c, C + +, C #, Java, JavaScript, Perl, Python, and so on). These features make JSON an ideal data exchange language.

JSON is constructed in two structures:

A collection of name/value pairs (A collection of name/value pairs). In different languages, it is understood as objects (object), records (record), structure (struct), dictionaries (dictionary), hash tables (hash table), a list of keys (keyed list), or associative arrays (associative Array).
The ordered list of values (an ordered list of values). In most languages, it is understood as an array.
These are common data structures. In fact most modern computer languages support them in some way. This makes it possible for a data format to be exchanged between programming languages that are also based on these constructs.

JSO official note See also: http://json.org/

Standard API Library Reference for Python operations JSON: http://docs.python.org/library/json.html

Encoding and decoding for simple data types:

Use a simple Json.dumps method to encode a simple data type, for example:

1 2 3 4 5 6 import  json   obj =  [[1, 2, 3], 123, 12 3.123, ' abc ', {' Key1 ':( 1, 2, 3), ' Key2 ':( 4, 5, 6)}] Encodedjson = 
Related Article

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.