Serialization using JSON

suggest change

JSON is a cross-language, widely used method to serialize data.

Supported data types: int, float, boolean, string, list, and dict. None becomes null, and a tuple is written as a list. See the JSON Wiki for more.

Here is an example demonstrating the basic usage of JSON:

import json

families = (['John'], ['Mark', 'David', {'name': 'Avraham'}])

# Dumping it into string
json_families = json.dumps(families)
# [["John"], ["Mark", "David", {"name": "Avraham"}]]

# Dumping it to file
with open('families.json', 'w') as json_file:
    json.dump(families, json_file)

# Loading it from string
json_families = json.loads(json_families)

# Loading it from file
with open('families.json', 'r') as json_file:
    json_families = json.load(json_file)

See JSON-Module for detailed information about JSON.

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents