Read and parse JSON in Python

Raymond Tang Raymond Tang 0 327 0.15 index 5/29/2019

JSON is commonly used in modern applications for data storage and transfers. Pretty much all programming languages provide APIs to parse JSON.

In Python, you can use json package to parse JSON. Function loads can be used to convert a string object to a JSON object.

Install the package via Pip:

pip install json

Code snippet

import json

jsonStr="""
{"Name":"A","Value":2}
"""
print(jsonStr)

json_obj = json.loads(jsonStr)
print(json_obj["Name"])
print(json_obj["Value"])
python python-file-operations

Join the Discussion

View or add your thoughts below

Comments