Very simple:
import json
data = json.loads('{"one" : "1", "two" : "2", "three" : "3"}')
print(data['two']) # or `print data['two']` in Python 2
Answer from John Giotta on Stack OverflowPython
docs.python.org โบ 3 โบ library โบ json.html
json โ JSON encoder and decoder
3 weeks ago - Return the Python representation of s (a str instance containing a JSON document). JSONDecodeError will be raised if the given JSON document is not valid. ... Decode a JSON document from s (a str beginning with a JSON document) and return a 2-tuple of the Python representation and the index in s where the document ended...
W3Schools
w3schools.com โบ python โบ python_json.asp
Python JSON
If you have a JSON string, you can parse it by using the json.loads() method. The result will be a Python dictionary.
Videos
03:30
How to Work with JSON Data in Python | Parse, Read & Write JSON ...
14:27
Python JSON Parsing: A Step-by-Step Guide to Extract Data from ...
09:10
๐ Python JSON Tutorial for Beginners: Read, Parse & Write JSON ...
12:57
Python Modules #4: json - JSON Encoder and Decoder. Working with ...
03:06
Working with JSON in Python: Encoding and Decoding - YouTube
06:32
JSON Python tutorial: what is JSON and how to parse JSON data with ...
Bobdc
bobdc.com โบ blog โบ pythonjson
Parsing JSON with Python
December 15, 2024 - My sample demo data to parse is pretty close to the test input that I used when I wrote about JSON2RDF: { "mydata": { "color": "red", "amount": 3, "arrayTest": [ "north", "south", "east", "escaped \"test\" string", "west" ], "boolTest": true, "nullTest": null, "addressBookEntry": { "givenName": "Richard", "familyName": "Mutt", "address": { "street": "1 Main St", "city": "Springfield", "zip": "10045" } } } } ... #!/usr/bin/env python3 import json f = open('jsondemo.js') data = json.load(f) print(data["mydata"]["color"]) print(data["mydata"]["amount"]) # Pull something out of the middle of an ar
GeeksforGeeks
geeksforgeeks.org โบ python โบ encoding-and-decoding-custom-objects-in-python-json
Encoding and Decoding Custom Objects in Python-JSON - GeeksforGeeks
January 24, 2026 - The object_hook parameter in json.loads() allows you to define how the JSON data is converted back into a Python object. By providing a custom object_hook function, you can control the deserialization process. ... import json # Custom decoder function def as_complex(dct): if '__complex__' in dct: return complex(dct['real'], dct['imag']) return dct # JSON string representing a complex number json_data = '{"__complex__": true, "real": 1, "imag": 2}' # Decoding using custom function com_num = json.loads(json_data, object_hook=as_complex) print(com_num) print(type(com_num))
Top answer 1 of 6
679
Very simple:
import json
data = json.loads('{"one" : "1", "two" : "2", "three" : "3"}')
print(data['two']) # or `print data['two']` in Python 2
2 of 6
103
For URL or file, use json.load(). For string with .json content, use json.loads().
#! /usr/bin/python
import json
# from pprint import pprint
json_file = 'my_cube.json'
cube = '1'
with open(json_file) as json_data:
data = json.load(json_data)
# pprint(data)
print "Dimension: ", data['cubes'][cube]['dim']
print "Measures: ", data['cubes'][cube]['meas']
Reddit
reddit.com โบ r/python โบ handling json files with ease in python
r/Python on Reddit: Handling JSON files with ease in Python
May 29, 2022 -
I have finished writing the third article in the Data Engineering with Python series. This is about working with JSON data in Python. I have tried to cover every necessary use case. If you have any other suggestions, let me know.
Working with JSON in Python
Data Engineering with Python series
NetworkAcademy
networkacademy.io โบ learning path: ccna automation (200-901) ccnaauto โบ data formats and data models โบ parsing json with python
Parsing JSON with Python | NetworkAcademy.IO
Import JSON moduleTo work with JSON data (string or JSON file), first, it has to be 'translated' into the python data structure. In this lesson, we are going to use python's built-in module json to do it.
ScrapingBee
scrapingbee.com โบ blog โบ how-to-read-and-parse-json-data-with-python
How to read and parse JSON data with Python | ScrapingBee
January 17, 2026 - In this article, you learned how to encode and decode a JSON string to a Python object and vice versa. Moreover, you saw how a custom encoder can be used to encode custom types to JSON. The json package is very versatile and provides a ton of additional features that are worth exploring.
Claudia Kuenzler
claudiokuenzler.com โบ blog โบ 1394 โบ how-to-handle-json-decode-error-python-script-try-except
How to handle JSON decode error in Python script with try and except
February 20, 2024 - However the error handler JSONDecodeError does not exist in the "global" namespace of the Python script and needs to be called from the json module: try: data = json.loads(output) except json.JSONDecodeError as e: print("Error: Unable to decode JSON, Error: {}. Manually run command ({}) to verify JSON output.".format(e, cmd))
QuickType
quicktype.io
Convert JSON to Swift, C#, TypeScript, Objective-C, Go, Java, C++ and more
quicktype generates types and helper code for reading JSON in C#, Swift, JavaScript, Flow, Python, TypeScript, Go, Rust, Objective-C, Kotlin, C++ and more. Customize online with advanced options, or download a command-line tool.
GeeksforGeeks
geeksforgeeks.org โบ python โบ python-jsondecoder-module
Python json.decoder Module - GeeksforGeeks
July 23, 2025 - JSONDecoder can be customized by overriding the default object_hook. This is a function that takes a dictionary and returns a dictionary. You can define your own conversions within this function.
W3Schools
w3schools.com โบ python โบ gloss_python_json_parse.asp
Python JSON Parse
The result will be a Python dictionary. ... import json # some JSON: x = '{ "name":"John", "age":30, "city":"New York"}' # parse x: y = json.loads(x) # the result is a Python dictionary: print(y["age"]) Try it Yourself ยป
Real Python
realpython.com โบ python-json
Working With JSON Data in Python โ Real Python
August 20, 2025 - That means you can conveniently convert Python data types into JSON data and the other way around. The act of converting data into the JSON format is referred to as serialization. This process involves transforming data into a series of bytes for storage or transmission over a network. The opposite process, deserialization, involves decoding data from the JSON format back into a usable form within Python.