Since you're using requests, you should use the response's json method.
import requests
response = requests.get(...)
data = response.json()
It autodetects which decoder to use.
Answer from pswaminathan on Stack Overflow Top answer 1 of 5
745
Since you're using requests, you should use the response's json method.
import requests
response = requests.get(...)
data = response.json()
It autodetects which decoder to use.
2 of 5
453
You can use json.loads:
import json
import requests
response = requests.get(...)
json_data = json.loads(response.text)
This converts a given string into a dictionary which allows you to access your JSON data easily within your code.
Or you can use @Martijn's helpful suggestion, and the higher voted answer, response.json().
W3Schools
w3schools.com › python › python_json.asp
Python JSON
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 »
Why Parse JSON With Python When Pandas Exists?
Pandas works well if you have JSON that is more or less a “record” — I.e. depth of 1 with a single value per field. Pandas is all about getting it into a dataframe, which is essentially a table. JSON can represent a lot more complicated objects. If you don’t have JSON that’s a “record” you’ll probably end up fighting against pandas. What’s your end objective? What are you trying to do with the JSON? More on reddit.com
How to check if something is in a JSON object before running if statement
There's no such thing as a "JSON object." There's a JSON string, which represents an object, but once you've deserialized the string you're holding a regular Python dictionary or list. So all of the regular Python membership tests work - you test whether the collection contains a key or a value by using in. The issue that I have run into so that sometimes those attributes (like subtitle) don't exist in the JSON because they do not exist in the file. if "subtitle" not in record or record["subtitle"] != "French": add_french_subtitles(record) # or whatever More on reddit.com
[Python] How to parse JSon response from a post request (Requests)
If I run your code I get NameError on session, maybe you need to define that for it to work? More on reddit.com
Parsing Json:API responses with Pydantic
Considering it's an OpenAPI spec you can simply use Pydantic datamodel code generation to build all the parsing models for you automagically. And the example they show should show you how nested models work. More on reddit.com
Videos
14:27
Python JSON Parsing: A Step-by-Step Guide to Extract Data from ...
11:43
How to Parse JSON in Python - JSON Tutorial for Python Beginners ...
03:30
How to Work with JSON Data in Python | Parse, Read & Write JSON ...
01:51
How to Correctly Parse JSON Response in Python to Avoid ...
08:47
HOW TO PARSE JSON FROM AN API: USING PYTHON
15:07
HOW TO PARSE DIFFERENT TYPES OF NESTED JSON ...
DZone
dzone.com › coding › languages › python: parsing a json http chunking stream
Python: Parsing a JSON HTTP Chunking Stream
December 4, 2015 - I use Python for most of my hacking these days and if HTTP requests are required the requests library is my first port of call. I started out with the following script: import requests import json def stream_meetup_initial(): uri = "http://stream.meetup.com/2/rsvps" response = requests.get(uri, stream = True) for chunk in response.iter_content(chunk_size = None): yield chunk for raw_rsvp in stream_meetup_initial(): print raw_rsvp try: rsvp = json.loads(raw_rsvp) except ValueError as e: print e continue ·
GitHub
googleapis.github.io › python-genai
Google Gen AI SDK documentation
user_profile = { 'properties': { 'age': { 'anyOf': [ {'maximum': 20, 'minimum': 0, 'type': 'integer'}, {'type': 'null'}, ], 'title': 'Age', }, 'username': { 'description': "User's unique name", 'title': 'Username', 'type': 'string', }, }, 'required': ['username', 'age'], 'title': 'User Schema', 'type': 'object', } response = client.models.generate_content( model='gemini-2.5-flash', contents='Give me a random user profile.', config={ 'response_mime_type': 'application/json', 'response_json_schema': user_profile }, ) print(response.parsed)
GitHub
github.com › openai › openai-python
GitHub - openai/openai-python: The official Python library for the OpenAI API · GitHub
To stream the response body, use .with_streaming_response instead, which requires a context manager and only reads the response body once you call .read(), .text(), .json(), .iter_bytes(), .iter_text(), .iter_lines() or .parse().
Starred by 30.3K users
Forked by 4.7K users
Languages Python
DataCamp
datacamp.com › tutorial › json-data-python
Python JSON Data: A Guide With Examples | DataCamp
December 3, 2024 - The if response.status_code == 200: line checks if the response code is 200, which means the request was successful. If the request is successful, the code then loads the response text into a Python dictionary using the json.loads() method and stores it in the data variable.
GeeksforGeeks
geeksforgeeks.org › python › response-json-python-requests
response.json() - Python requests - GeeksforGeeks
July 12, 2025 - When we print the response it prints '<Response [200]>' which is the HTTP code that indicates success. To print the JSON data fetched we have used json() method which prints the JSON data in the Python dictionary format as seen in the output. In this way, we can pas parse JSON responses in Python.
Axios
axios-http.com › docs › intro
Getting Started | Axios Docs
Automatic JSON data handling in response · Progress capturing for browsers and node.js with extra info (speed rate, remaining time) Setting bandwidth limits for node.js · Compatible with spec-compliant FormData and Blob (including node.js) Client side support for protecting against XSRF ·
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 »
freeCodeCamp
freecodecamp.org › news › how-to-parse-json-in-python-with-examples
How to Parse JSON in Python – A Complete Guide With Examples
October 29, 2025 - JSON arrays represent ordered lists of values and appear frequently in API responses when returning collections of items. Python converts JSON arrays into lists, which you can iterate through or access by index. Here's an example parsing a list of products from an inventory system:
Google
developers.google.com › google maps platform › web services › geocoding api › geocoding api overview
Geocoding API overview | Google for Developers
The Java Client, Python Client, Go Client and Node.js Client for Google Maps Services are community-supported client libraries, open sourced under the Apache 2.0 License. Download them from GitHub, where you can also find installation instructions and sample code. Start using the Geocoding API: Go to Set up your Google Cloud project. Get started with sample requests and responses: Go to Geocoding requests and responses
Schulich School of Engineering
schulich.libguides.com › c.php
Parsing JSON Responses in Python - Getting Started With APIs - SSE Tech Support at Schulich School of Engineering - University of Calgary
July 30, 2024 - # Import the requests library import requests # Define parameters for continent and city params = { "continent": "Africa", "city": "Casablanca" } # Construct the API endpoint URL using the provided continent and city url = "http://worldtimeapi.org/api/timezone/" # Make a GET request to the API json_response = requests.get(url + f"{params['continent']}/{params['city']}") # Print the unparsed JSON response print(json_response) ... Notice that this code gives us the status code as a response instead of the current time in Casablanca like we want it to. Now let's add a little more code to parse the JSON response and see where that gets us: