Sometimes, we want to convert dictionary to JSON with Python.
In this article, we’ll look at how to convert dictionary to JSON with Python.
How to convert dictionary to JSON with Python?
To convert dictionary to JSON with Python, we can use the json.dumps
method.
For instance, we write
import json
r = {'is_claimed': 'True', 'rating': 3.5}
r = json.dumps(r)
to call json.dumps
with dict r
to convert the dict into a JSON string.
Conclusion
To convert dictionary to JSON with Python, we can use the json.dumps
method.