What is JSON:
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 collection of name/value pairs (A collection of name/value pairs). In different languages, it is understood as objects (object), record (record), structure (struct), Dictionary (dictionary), hash table (hash table), keyed list (keyed list), or associative array (associative Array).
The sequence of values (an ordered list of values). In most languages, it is understood as an array (array).
These are common data structures. In fact, most of the modern computer languages support them in some form. This makes it possible for a data format to be exchanged between programming languages that are also based on these constructs.
JSO Official notes See: http://json.org/
Standard API Library Reference for Python operation JSON: http://docs.python.org/library/json.html
Load & Dump:
The most common method of JSON is JSON type and str type conversion, where load and dump are methods for files, loads and dumps are methods for strings
ImportJSON#Example.json#{"A": 1, "B": "CCC"}With open ("Example.json") as F:a=json.load (f) f.seek (0) b=json.loads (F.read ())#A and B are the same, all JSON typesC=Json.dumps (a)#c is str typeWith open ("Out.json","W") as F:json.dump (A, F)#write a back to Out.json
The types of JSON are converted as follows:
A = {"a": {'T1':'T2'},'b': ['L1','L2'],'C':'KHJ','D': 1.23,'e': 456,'F': True,'g': None}json.dumps (a)#' {"a": {"T1": "T2"}, "C": "KHJ", "B": ["L1", "L2"], "E": 456, "D": 1.23, "G": null, "F": true} '
Python JSON usage