The json Module for JSON Serialization and Deserialization in Python


Work with JSON data.

Source Code

import json

# Convert dictionary to JSON string
data = {"name": "John", "age": 30}
json_str = json.dumps(data)
print(json_str)

# Convert JSON string back to dictionary
data = json.loads(json_str)
print(data)
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments