If you want to iterate over both keys and values of the dictionary, do this:

for key, value in data.items():
    print(key, value)
Answer from Lior on Stack Overflow
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ python โ€บ python-program-to-extract-a-single-value-from-json-response
Python program to extract a single value from JSON response - GeeksforGeeks
July 23, 2025 - Import JSON from the modules. Open the JSON file in read-only mode using the Python with() function. Load the JSON data into a variable using the Python load() function. Now, get the value of keys in a variable.
๐ŸŒ
Real Python
realpython.com โ€บ python-json
Working With JSON Data in Python โ€“ Real Python
August 20, 2025 - The Python object that you get from json.load() depends on the top-level data type of your JSON file. In this case, the JSON file contains an object at the top level, which deserializes into a dictionary. When you deserialize a JSON file as a Python object, then you can interact with it nativelyโ€”for example, by accessing the value of the "name" key with square bracket notation ([]).
๐ŸŒ
W3Schools
w3schools.com โ€บ python โ€บ python_json.asp
Python JSON
The json.dumps() method has parameters to make it easier to read the result: Use the indent parameter to define the numbers of indents: ... You can also define the separators, default value is (", ", ": "), which means using a comma and a space ...
๐ŸŒ
Zyte
zyte.com โ€บ home โ€บ blog โ€บ json parsing with python [practical guide]
JSON Parsing with Python [Practical Guide]
July 6, 2023 - In JSON, data is typically stored in either an array or an object. To access data within a JSON array, you can use array indexing, while to access data within an object, you can use key-value pairs.
๐ŸŒ
DEV Community
dev.to โ€บ bluepaperbirds โ€บ get-all-keys-and-values-from-json-object-in-python-1b2d
Get all keys and values from json object in Python - DEV Community
January 12, 2021 - In our json file there's a header named emp_details. jsonData = data["emp_details"] keys = x.keys() values = x.values() ... import json with open("test.json") as jsonFile: data = json.load(jsonFile) jsonData = data["emp_details"] for x in jsonData: ...
Find elsewhere
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ python โ€บ read-json-file-using-python
Read JSON file using Python - GeeksforGeeks
... We will be using Pythonโ€™s json module, which offers several methods to work with JSON data. In particular, loads() and load() are used to read JSON from strings and files, respectively.
Published ย  September 15, 2025
๐ŸŒ
Python Guides
pythonguides.com โ€บ json-data-in-python
How To Get Values From A JSON Array In Python?
November 29, 2024 - Let me show you another way to extract values from a JSON array is: by using list comprehension. List comprehension allows you to create a new list based on an existing list or iterable. Hereโ€™s an example: import json # Load JSON data from file with open('C:/Users/fewli/Downloads/Python/states.json') as file: data = json.load(file) state_names = [state['name'] for state in data] print("State Names:", state_names)
๐ŸŒ
Like Geeks
likegeeks.com โ€บ home โ€บ python โ€บ how to get json value by key in python
How To Get JSON Value by Key in Python
By converting the JSON string to a Python dictionary using json.loads(), you can retrieve any value by simply referencing its key. Using the get() method to access values provides a safer alternative to direct key access.
๐ŸŒ
Medium
medium.com โ€บ @sharath.ravi โ€บ python-function-to-extract-specific-key-value-pair-from-json-data-7c063ecb5a15
Python function to extract specific key value pair from json data. | by Sharath Ravi | Medium
April 6, 2023 - import json def extract_key_va... example, the function extract_key_value takes two arguments: json_data, which is a string containing JSON data, and key, which is the key for the value that you want to extract. The function first uses the json.loads method to convert the json_data string into a Python dictionary...
๐ŸŒ
TutorialsPoint
tutorialspoint.com โ€บ python-program-to-extract-a-single-value-from-json-response
Python program to extract a single value from JSON response
Now that we have a brief knowledge about a JSON response, let's understand the extraction part. In this approach, we will use an API endpoint to retrieve data from the server. Firstly, we will import the "requests" library to handle the HTTP request. We will then use the "get()" method to send ...
๐ŸŒ
Python
docs.python.org โ€บ 3 โ€บ library โ€บ json.html
json โ€” JSON encoder and decoder
fp (file-like object) โ€“ A .read()-supporting text file or binary file containing the JSON document to be deserialized. cls (a JSONDecoder subclass) โ€“ If set, a custom JSON decoder. Additional keyword arguments to load() will be passed to the constructor of cls. If None (the default), JSONDecoder is used. object_hook (callable | None) โ€“ If set, a function that is called with the result of any JSON object literal decoded (a dict). The return value of this function will be used instead of the dict.
๐ŸŒ
Linux Hint
linuxhint.com โ€บ search_json_python
How to search for data in JSON using python โ€“ Linux Hint
The following script shows steps on searching the value of a particular key in the nested JSON data. Here, a nested JSON variable named nestedData is declared to store nested data. This script will search the brand name of the women watch. #!/usr/bin/env python3 # Import json module import json # Define json variable of nested data nestedData = """{ "watch":{ "men":{ "brand":"Titan", "price":200 }, "women":{ "brand":"Citizen", "price":250 }, "kid":{ "brand":"Blancpain", "price":100 } } }""" # Load the json data watchlist = json.loads(nestedData) # Search 'brand' for women if 'brand' in watchlist['watch']['women']: print(watchlist['watch']['women']['brand'])
๐ŸŒ
Reddit
reddit.com โ€บ r/learnpython โ€บ only read the value of a specific key from json file?
r/learnpython on Reddit: Only read the value of a specific key from JSON file?
October 20, 2023 -

Wondering if thereโ€™s a way to do this with the standard json module. Looking to just extract the value of 1 key from a large json file without needing to load the whole thing

For example, I had a json file with:

{
  โ€œxโ€: โ€ฆ,
  โ€œyโ€: โ€ฆ,
  โ€œzโ€: โ€ฆ
}

is there a way of doing something like json.load(โ€ฆ) but only reading everything under key โ€œyโ€ for example?

๐ŸŒ
Oxylabs
oxylabs.io โ€บ blog โ€บ python-parse-json
Reading & Parsing JSON Data With Python: Tutorial
To put it simply, extracting data from a JSON file in Python requires reading the file, parsing its contents using the JSON module, and storing the data in a dictionary or list. You can then access specific values using dictionary keys or list ...
๐ŸŒ
Programiz
programiz.com โ€บ python-programming โ€บ json
Python JSON: Read, Write, Parse JSON (With Examples)
Here, we have used the open() function to read the json file. Then, the file is parsed using json.load() method which gives us a dictionary named data. If you do not know how to read and write files in Python, we recommend you to check Python File I/O.
๐ŸŒ
Robotastemtraining
robotastemtraining.com โ€บ read โ€บ how-do-you-get-all-values-by-key-with-json-and-python
How Do You Get All Values by Key with JSON and Python?
# Load JSON from a string json_data ... "Alex", "age": 7 } ] } ''' data = json.loads(json_data) Define a recursive function to traverse the JSON object and extract all values associated with the specified key. def get_values_by_key(data, key): values = [] def extract(data, ...
๐ŸŒ
Quora
quora.com โ€บ How-do-you-get-all-values-by-key-with-JSON-and-Python
How to get all values by key with JSON and Python - Quora
Answer: You can use the [code ]json[/code] library in Python to get values associated with a key in a JSON object. Here's an example: [code]import json # sample JSON data data = """ { "employees": [ { "firstName": "John", "lastName": "Doe" }, ...