Development Category (English)728x90

Python JSON

JSON (JavaScript Object Notation) is often used on the web to exchange data.

JSON can be encoded and decoded with Python. That means you can convert from Python objects to JSON objects and vice-versa.

Related course:
Python Beyond the Basics – Object-Oriented Programming

Python json dumps

In the example below we convert a Python object to a JSON object.

Start with a class (Student), create the object (pythonObj) and
finally convert it to JSON using the method json.dumps().

This outputs:

Python json loads

If you want to convert JSON data to a Python dictionary, just use loads:

To convert it to a Python object, define the class and pass the parameters as a map.

Previous Post
Next Post

Leave a Reply