How to Convert From JSON to Python in Python


In this example, we will learn how to convert from JSON to Python.

Source Code

import json

# JSON data
my_json = '{ "name":"Jim", "age":14, "id":"15"}'

# parse JSON data
json_to_python = json.loads(my_json)

# the result is a Python dictionary:
print(json_to_python)
print(json_to_python['name'])

Output:

{'name': 'Jim', 'age': 14, 'id': '15'}
Jim
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments
Advertisement