Working with JSON in Python


Learn how to serialize and deserialize JSON data, a common format for data interchange on the web.

Source Code

import json
# Convert a dictionary to a JSON string
my_dict = {"name": "John", "age": 30, "city": "New York"}
json_str = json.dumps(my_dict)
# Convert a JSON string back to a dictionary
new_dict = json.loads(json_str)
print(new_dict)
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments