json — Easy Playground
Encode and decode JSON data
Python Playground
import json
# Convert Python to JSON
data = {"name": "Python", "version": 3, "features": ["easy", "powerful"]}
json_str = json.dumps(data, indent=2)
print(json_str)
# Convert JSON to Python
parsed = json.loads(json_str)
print(parsed["name"])
Output
Click "Run" to execute your code
The json module is part of Python's standard library. Encode and decode JSON data.
Challenge
Try modifying the code above to explore different behaviors. Can you extend the example to handle a new use case?