Python JSON: Convert JSON data to Python object
1. Convert JSON Data to Python Object
Write a Python program to convert JSON data to Python object.
Sample Solution:-
Python Code:
import json
json_obj = '{ "Name":"David", "Class":"I", "Age":6 }'
python_obj = json.loads(json_obj)
print("\nJSON data:")
print(python_obj)
print("\nName: ",python_obj["Name"])
print("Class: ",python_obj["Class"])
print("Age: ",python_obj["Age"])
Output:
JSON data: {'Name': 'David', 'Class': 'I', 'Age': 6} Name: David Class: I Age: 6
Flowchart:

For more Practice: Solve these Related Problems:
- Write a Python program to convert a nested JSON string into a Python dictionary and extract a specific nested value.
- Write a Python program to parse a JSON array into a Python list and filter its elements based on a condition.
- Write a Python program to recursively convert a JSON string with multiple levels of nesting into Python objects and print its structure.
- Write a Python program to load a JSON string containing mixed data types and display the type of each element in the resulting Python object.
Python Code Editor:
Have another way to solve this solution? Contribute your code (and comments) through Disqus.
Previous: Python JSON Exercises Home.
Next: Write a Python program to convert Python object to JSON data.
What is the difficulty level of this exercise?
Test your Programming skills with w3resource's quiz.