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
🌐
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_value(json_data, key): """Extracts a specific key-value pair from a JSON data""" data = json.loads(json_data) value = data.get(key) return value · In this example, the function extract_key_value takes two arguments: ...
Discussions

Json.loads only returns names but not the values
Hi everyone Tho I have lots of programming experience, I’m new to python and, of course, spyder. I have been following some youtube tutorial videos and now am trying out some api calls. I’m using Spyder 5.5.1 Here’s the code: import requests import json response = requests.get("https... More on discuss.python.org
🌐 discuss.python.org
0
0
March 19, 2024
How to get values from all instances of key in JSON in Python - Stack Overflow
If I loop through the response and try to append the value, I get: TypeError: the JSON object must be str, bytes or bytearray, not list ... You should work through the Python tutorial if not done yet. More on stackoverflow.com
🌐 stackoverflow.com
Get value from JSON
How can I get a certain value out of JSON if I know one specific value. If I want to extract car type and I know the car name. I have try different variations of this: ${GetType}= Get Value From Json ${CarList.json()} $…type[?($.name=Focus)] [ { "Manuafacture": "BMW", "Engine": [ { "volume": ... More on forum.robotframework.org
🌐 forum.robotframework.org
0
0
October 31, 2023
python - How to parse json to get all values of a specific key within an array? - Stack Overflow
I'm having trouble trying to get a list of values from a specific key inside an json array using python. Using the JSON example below, I am trying to create a list which consists only the values of... More on stackoverflow.com
🌐 stackoverflow.com
🌐
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 ...
🌐
Python.org
discuss.python.org › python help
Json.loads only returns names but not the values - Python Help - Discussions on Python.org
March 19, 2024 - Hi everyone Tho I have lots of programming experience, I’m new to python and, of course, spyder. I have been following some youtube tutorial videos and now am trying out some api calls. I’m using Spyder 5.5.1 Here’s the code: import requests import json response = requests.get("https://jsonplaceholder.typicode.com/todos/1") print(response.status_code) print(response.text) res = json.loads(response.text) for data in res: print(data) Here’s the output: 200 ← status code is good Next i...
🌐
Zyte
zyte.com › home › blog › json parsing with python [practical guide]
JSON Parsing with Python [Practical Guide]
December 3, 2024 - After loading JSON data into Python, you can access specific data elements using the keys provided in the JSON structure. 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.
🌐
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
... Use the recursive generator for most cases; switch to jsonpath-ng for expressive queries or ijson for very large files. ... You can use the json library in Python to get values associated with a key in a JSON object.
Find elsewhere
🌐
PYnative
pynative.com › home › python › json › python check if key exists in json and iterate the json array
Python Check if key exists in JSON and iterate the JSON array
May 14, 2021 - In this article, we will see how to perform the following JSON operations using Python. ... Let’s see each one by one. ... Let’s assume you received the following student, JSON. And you wanted to check if the percentage key is present or not in JSON data. if it is present directly to access its value instead of iterating the entire JSON.
🌐
Python Forum
python-forum.io › thread-37297.html
Trying to parse only 3 key values from json file
So im playing around with parsing a json file in python. Im able to read in the file and print it to the console, but now i want to extract 3 values from each 'section' not sure what the proper terminology is. Here is a example of the data structure...
🌐
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.
🌐
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 - import json with open("test.json") as jsonFile: data = json.load(jsonFile) jsonData = data["emp_details"] for x in jsonData: keys = x.keys() print(keys) values = x.values() print(values) ...
🌐
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 - You'll use it to convert JSON strings into Python dictionaries and lists that you can manipulate with familiar syntax, and then convert your Python data structures back into JSON when you need to send data to an API or save it to a file. Beyond basic parsing, you'll often need to handle nested structures, validate data integrity, manage, and transform data formats. This guide covers practical JSON parsing techniques you can use in your projects right away. Let’s get started! ... JSON represents data using a simple syntax with six data types: objects (key-value pairs), arrays, strings, numbers, Booleans, and null.
🌐
GitHub
github.com › nlohmann › json
GitHub - nlohmann/json: JSON for Modern C++ · GitHub
When using get<your_type>(), your_type MUST be DefaultConstructible. (There is a way to bypass this requirement described later.) In function from_json, use function at() to access the object values rather than operator[]. In case a key does not exist, at throws an exception that you can handle, ...
Starred by 49.1K users
Forked by 7.3K users
Languages   C++ 96.9% | CMake 2.0% | Python 0.6% | Makefile 0.3% | Starlark 0.1% | Jinja 0.1%
🌐
TutorialsPoint
tutorialspoint.com › python-program-to-extract-a-single-value-from-json-response
Python program to extract a single value from JSON response
July 12, 2023 - We will use the keys to extract single and multiple values. Refer to this link for official documentation ? https://apipheny.io/free-api/ The API URL link ?https://api.coindesk.com/v1/bpi/currentprice.json · Following is an example to extract a single value from a JSON response using an "CoinDesk" API - import requests print("Welcome to the live bitcoin Price index") Json_data = requests.get('https://api.coindesk.com/v1/bpi/currentprice.json').json() Disclaimer = Json_data["disclaimer"] print(Disclaimer) BPI = Json_data["bpi"]["USD"]["rate"] print(f"The real time BPI value for the United states of America is: {BPI}") TIME = Json_data["time"]["updated"] print(f"The index was viewed at Universal time: {TIME}")
🌐
Claudia Kuenzler
claudiokuenzler.com › blog › 1395 › how-to-iterate-nested-json-dict-search-specific-value-print-key-python
How to iterate through a nested JSON, search for a specific value and print the key with Python
February 27, 2024 - While I was working on a Python script, I needed to find a way to iterate through a nested JSON (which is actually a dict inside Python), search for a specific field (key) and if the value of this key meets a condition, print the parent (top layer) key.
🌐
YouTube
youtube.com › watch
Python JSON Parsing: A Step-by-Step Guide to Extract Data from JSON - YouTube
In this comprehensive tutorial, learn the ins and outs of Python JSON parsing. Dive into the world of data manipulation as we explore the essential technique...
Published   August 20, 2023
🌐
Bright Data
brightdata.com › blog › how-tos › parse-json-data-with-python
Guide to Parsing JSON Data With Python
September 16, 2025 - Take a look at the conversion table below to see how JSON values are converted to Python data by json: Consider that you need to make an API and convert its JSON response to a Python dictionary. In the example below, we will call the following API endpoint from the {JSON} Placeholder project to get ...
🌐
Robot Framework
forum.robotframework.org › robot framework
Get value from JSON - Robot Framework - Robot Framework
October 31, 2023 - How can I get a certain value out of JSON if I know one specific value. If I want to extract car type and I know the car name. I have try different variations of this: ${GetType}= Get Value From Json ${CarList.json()} $…type[?($.name=Focus)] [ { "Manuafacture": "BMW", "Engine": [ { "volume": 3, "filter": 222, "name": "Turbo-dd" } ], "name": "320", "type": "333-44-12" }, { "Manuafacture": "Ford", "Engine": [ { ...
Top answer
1 of 3
18

You cannot do contents[:]["name"] since contents is a list is a dictionary with integer indexes, and you cannot access an element from it using a string name.

To fix that, you would want to iterate over the list and get the value for key name for each item

import json
contents = []

try:
    with open("./simple.json", 'r') as f:
        contents = json.load(f)
except Exception as e:
    print(e)


li = [item.get('name') for item in contents]
print(li)

The output will be

['Bulbasaur', 'Ivysaur']
2 of 3
6

This is not a real answer to the question. The real answer is to use a list comprehension. However, you can make a class that allows you to use specifically the syntax you tried in the question. The general idea is to subclass list so that a slice like [:] returns a special view (another class) into the list. This special view will then allow retrieval and assignment from all the dictionaries simultaneously.

class DictView:
    """
    A special class for getting and setting multiple dictionaries
    simultaneously. This class is not meant to be instantiated
    in its own, but rather in response to a slice operation on UniformDictList.
    """
    def __init__(parent, slice):
        self.parent = parent
        self.range = range(*slice.indices(len(parent)))

    def keys(self):
        """
        Retreives a set of all the keys that are shared across all
        indexed dictionaries. This method makes `DictView` appear as
        a genuine mapping type to `dict`.
        """
        key_set = set()
        for k in self.range:
            key_set &= self.parent.keys()
        return key_set

    def __getitem__(self, key):
        """
        Retreives a list of values corresponding to all the indexed
        values for `key` in the parent. Any missing key will raise
        a `KeyError`.
        """
        return [self.parent[k][key] for k in self.range]

    def get(self, key, default=None):
        """
        Retreives a list of values corresponding to all the indexed
        values for `key` in the parent. Any missing key will return
        `default`.
        """
        return [self.parent[k].get(key, default) for k in self.range]

    def __setitem__(self, key, value):
        """
        Set all the values in the indexed dictionaries for `key` to `value`.
        """
        for k in self.range:
            self.parent[k][key] = value

    def update(self, *args, **kwargs):
        """
        Update all the indexed dictionaries in the parent with the specified
        values. Arguments are the same as to `dict.update`.
        """
        for k in self.range:
             self.parent[k].update(*args, **kwargs)


class UniformDictList(list):
    def __getitem__(self, key):
        if isinstance(key, slice):
            return DictView(self, key)
        return super().__getitem__(key)

Your original code would now work out of the box with just one additional wrap in UniformDictList:

import json
try:
    with open("./simple.json", 'r') as f:
        contents = UniformDictList(json.load(f))
except Exception as e:
    print(e)

print(contents[:]["name"])