json
- Function: Converts lists, tuples, and dictionaries into JSON strings
- JSON: JavaScriptObjectNotation chords (JS), is a lightweight data-interchange format, based on a subset of the ECMAScript, completely independent of the programming language of the text format is used to store and said object
Four methods
1. dumps
- Convert dictionaries, lists, collections, tuples, and so on to JSON strings
- The JSON string is the same as that of the dictionary. Operations related to the dictionary cannot be performed
2. dump
3. loads
- Converts a JSON string to a raw Python data type
- With the eval
4. load
Python data types versus JSON data types
Python | json |
---|---|
string | string |
The dictionary | object |
List, tuple | An array of |
Boolean | Boolean |
- Tuples are converted to arrays and then to lists, but cannot be converted to tuples