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
chwang12341.medium.com › 寫給自己的技術筆記-作為程式開發者我們絕對不能忽略的json-python-如何處理json文件-b227b7e610a8
寫給自己的技術筆記— 作為程式開發者我們絕對不能忽略的JSON
February 1, 2021 - ​ import json ​ ## 讀取JSON檔 with open('test.json', 'r') as f: ## 將內容裝進text text = f.read() print("JSON Format: ", text) print("Type: ", type(text)) print("From JSON String Transform To Python Dict") print("Python Dict: ", json.loads(text)) print("Type: ", type(json.loads(text))) ​
Discussions

python - Reading JSON from a file - Stack Overflow
The distinction between undefined and empty is not always going to be made clear in JSON files. For example, several popular non-python librariesl convert empty lists (and empty dicts) into JSON null. 2024-06-25T10:43:19.273Z+00:00 ... You may want to wrap your json.load line with a try catch, ... More on stackoverflow.com
🌐 stackoverflow.com
What is the difference between json.load() and ...
Tutorial about json.dump/dumps & json.load/loads bogotobogo.com/python/… 2019-12-10T16:17:37.16Z+00:00 More on stackoverflow.com
🌐 stackoverflow.com
JSON load() vs loads()

load() loads JSON from a file or file-like object

loads() loads JSON from a given string or unicode object

It's in the documentation

More on reddit.com
🌐 r/learnpython
7
6
December 2, 2013
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 … More on discuss.python.org
🌐 discuss.python.org
0
March 19, 2024
🌐
GeeksforGeeks
geeksforgeeks.org › python › json-loads-in-python
json.loads() in Python - GeeksforGeeks
Explanation: json.loads(s) parses the JSON string s and converts it into a Python dict.
Published   January 13, 2026
🌐
Python
docs.python.org › 3 › library › json.html
json — JSON encoder and decoder
3 weeks ago - parse_constant doesn’t get called on ‘null’, ‘true’, ‘false’ anymore. ... All optional parameters are now keyword-only. fp can now be a binary file. The input encoding should be UTF-8, UTF-16 or UTF-32. Changed in version 3.11: The default parse_int of int() now limits the maximum length of the integer string via the interpreter’s integer string conversion length limitation to help avoid denial of service attacks. json.loads(s, *, cls=None, object_hook=None, parse_float=None, parse_int=None, parse_constant=None, object_pairs_hook=None, **kw)¶
🌐
W3Schools
w3schools.com › PYTHON › python_json.asp
Python JSON
Python has a built-in package called json, which can be used to work with JSON data. ... If you have a JSON string, you can parse it by using the json.loads() method.
🌐
Real Python
realpython.com › python-json
Working With JSON Data in Python – Real Python
August 20, 2025 - How can you read JSON data from a file into a Python program?Show/Hide · You can use the json.load() function to deserialize JSON data from a file into a Python object.
Find elsewhere
Top answer
1 of 6
306

Yes, s stands for string. The json.loads function does not take the file path, but the file contents as a string. Look at the documentation.

Simple example:

with open("file.json") as f:
  data = json.load(f)  # ok

  data = json.loads(f)  # not ok, f is not a string but a file
text = '{"a": 1, "b": 2}'  # a string with json encoded data
data = json.loads(text) 
2 of 6
138

Just going to add a simple example to what everyone has explained,

json.load()

json.load can deserialize a file itself i.e. it accepts a file object, for example,

# open a json file for reading and print content using json.load
with open("/xyz/json_data.json", "r") as content:
  print(json.load(content))

will output,

{u'event': {u'id': u'5206c7e2-da67-42da-9341-6ea403c632c7', u'name': u'Sufiyan Ghori'}}

If I use json.loads to open a file instead,

# you cannot use json.loads on file object
with open("json_data.json", "r") as content:
  print(json.loads(content))

I would get this error:

TypeError: expected string or buffer

json.loads()

json.loads() deserialize string.

So in order to use json.loads I will have to pass the content of the file using read() function, for example,

using content.read() with json.loads() return content of the file,

with open("json_data.json", "r") as content:
  print(json.loads(content.read()))

Output,

{u'event': {u'id': u'5206c7e2-da67-42da-9341-6ea403c632c7', u'name': u'Sufiyan Ghori'}}

That's because type of content.read() is string, i.e. <type 'str'>

If I use json.load() with content.read(), I will get error,

with open("json_data.json", "r") as content:
  print(json.load(content.read()))

Gives,

AttributeError: 'str' object has no attribute 'read'

So, now you know json.load deserialze file and json.loads deserialize a string.

Another example,

sys.stdin return file object, so if i do print(json.load(sys.stdin)), I will get actual json data,

cat json_data.json | ./test.py

{u'event': {u'id': u'5206c7e2-da67-42da-9341-6ea403c632c7', u'name': u'Sufiyan Ghori'}}

If I want to use json.loads(), I would do print(json.loads(sys.stdin.read())) instead.

🌐
Spark By {Examples}
sparkbyexamples.com › home › python › python json.loads() method with examples
Python json.loads() Method with Examples
May 31, 2024 - The json loads() is a method from the json Python module that is used to parse a JSON (JavaScript Object Notation) string and convert it into a Python object.
🌐
Reddit
reddit.com › r/learnpython › json load() vs loads()
r/learnpython on Reddit: JSON load() vs loads()
December 2, 2013 -

Can someone explain what the difference is between using either load() or loads() is with the JSON library? And which, if either, is the preferred method.

I'm writing a simple script where I want the JSON data from a URL parsed out into a list. Both of these options seem to work:

import json
import urllib2

url = "string to url"

response = urllib2.urlopen(url)
data = json.load(response)

or

import json
import urllib2

url = "string to url"

response = urllib2.urlopen(url)
data = json.loads(response.read())

I know that there are other libraries available for parsing out JSON data, but for the time being I'm working only with the json and urllib2 libraries.

Any insight into which one should be used?

Thanks

🌐
Analytics Vidhya
analyticsvidhya.com › home › python json.loads() and json.dump() methods
Python json.loads() and json.dump() methods - Analytics Vidhya
May 1, 2025 - The json.loads() function automatically converts JSON data types to their corresponding Python data types. For example, JSON strings are converted to Python strings, JSON numbers are converted to Python integers or floats, and JSON arrays are ...
🌐
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...
🌐
Imperial College London
python.pages.doc.ic.ac.uk › java › lessons › java › 10-files › 03-load.html
Python for Java Programmers > Loading JSON files
To load your object directly from a JSON string rather than a file, use json.loads(string) (loads is short for ‘load string’). import json json_string = '[{"id": 2, "name": "Basilisk"}, {"id": 6, "name": "Nagaraja"}]' data = json.loads(json_string) print(data[0]) # {'id': 2, 'name': 'Basilisk'} ...
🌐
Python.org
discuss.python.org › typing
Stdlib json.load[s]() return type - Typing - Discussions on Python.org
October 13, 2024 - The json.load and json.loads both return typing.Any but why? Shouldn’t they be dict[str, Any] · That’s pretty solvable with overloads (passing cls or any of the hooks uses an overload which returns Any). Last I heard, the issue with the return type (and the input to dump) was due to recursion ...
🌐
GeeksforGeeks
geeksforgeeks.org › python › json-load-in-python
json.load() in Python - GeeksforGeeks
August 11, 2025 - import json # Opening and reading the JSON file with open('data.json', 'r') as f: # Parsing the JSON file into a Python dictionary data = json.load(f) # Iterating over employee details for emp in data['emp_details']: print(emp)
🌐
Opensource.com
opensource.com › article › 19 › 7 › save-and-load-data-python-json
Save and load Python data with JSON | Opensource.com
This function implements the inverse, more or less, of saving the file: an arbitrary variable (f) represents the data file, and then the JSON module’s load function dumps the data from the file into the arbitrary team variable. The print statements in the code sample demonstrate how to use the data. It can be confusing to compound dict key upon dict key, but as long as you are familiar with your own dataset, or else can read the JSON source to get a mental map of it, the logic makes sense.
🌐
Codecademy
codecademy.com › docs › python › json module › .load()
Python | JSON Module | .load() | Codecademy
May 29, 2025 - Returns a Python object (dictionary, list, string, number, boolean, or None) representing the parsed JSON data. This example demonstrates the fundamental usage of json.load() to read JSON data from a file:
🌐
Medium
medium.com › @gadallah.hatem › the-difference-between-json-loads-and-json-load-2dbd30065f26
The difference between json.loads() and ...
December 15, 2024 - Get app · Write · Search · Sign ... where they are commonly used · Stands for: Load String · Purpose: Converts a JSON-encoded string into a Python object (e.g., dictionary or list)....