Read and parse JSON in Python

access_time 2 years ago visibility18 comment 0

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"])
info Last modified by Administrator at 2 months ago copyright This page is subject to Site terms.
Like this article?
Share on

Please log in or register to comment.

account_circle Log in person_add Register

Log in with external accounts

Want to publish your article on Kontext?

Learn more

Kontext Column

Created for everyone to publish data, programming and cloud related articles.
Follow three steps to create your columns.


Learn more arrow_forward

More from Kontext

local_offer teradata local_offer python local_offer python-database

visibility 13696
thumb_up 1
access_time 3 years ago

Teradata published an official Python module which can be used in DevOps projects. More details can be found at the following GitHub site: https://github.com/Teradata/PyTd If pip is installed, you can directly install this module through the following command: pip install Teradata If not ...

local_offer python

visibility 33
thumb_up 1
access_time 11 months ago

Different programming languages have different package management tools.

local_offer python local_offer python-file-operations

visibility 65
thumb_up 0
access_time 19 days ago

XML is a commonly used data exchange format in many applications and systems though JSON became more popular nowadays. Compared with JSON, XML supports schema (XSD) validation and can be easily transformed other formats using XSLT. XHTML is also a strict version of HTML that is XML based and used ...

About column

Code snippets for various programming languages/frameworks.

rss_feed Subscribe RSS