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 = |