JSON, or JavaScript Object Notation, is a widely-used text-based format for data
interchange. Its syntax resembles Python dictionaries but with some differences,
such as using only double quotes for strings and lowercase for Boolean values.
Reading links:
[Link]
[Link]
utm_source=realpython&utm_medium=web&utm_campaign=related-post&utm_content=python-
json
[Link]
utm_source=realpython&utm_medium=web&utm_campaign=related-post&utm_content=python-
json
[Link]
[Link]
The act of converting data into the JSON format is referred to as serialization.
This process involves transforming data into a series of bytes for storage or
transmission over a network. The opposite process, deserialization, involves
decoding data from the JSON format back into a usable form within Python.
import json
dog_data = {
"name": "Frieda",
"is_dog": True,
"hobbies": ["eating", "sleeping", "barking",],
"age": 8,
"address": {
"work": None,
"home": ("Berlin", "Germany",),
},
"friends": [
{
"name": "Philipp",
"hobbies": ["eating", "sleeping", "reading",],
},
{
"name": "Mitch",
"hobbies": ["running", "snacking",],
},
],
}
with open("hello_frieda.json", mode="w", encoding="utf-8") as write_file:
[Link](dog_data, write_file)