๐ŸŒ
Python
docs.python.org โ€บ 3 โ€บ library โ€บ json.html
json โ€” JSON encoder and decoder โ€” Python 3.14.7 documentation
As a result of this, if a dictionary is converted into JSON and then back into a dictionary, the dictionary may not equal the original one. That is, loads(dumps(x)) != x if x has non-string keys.
๐ŸŒ
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.
๐ŸŒ
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 ยป
๐ŸŒ
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
๐ŸŒ
Codecademy
codecademy.com โ€บ docs โ€บ python โ€บ json module โ€บ .load()
Python | JSON Module | .load() | Codecademy
May 29, 2025 - The .load() method in Pythonโ€™s JSON module is used to parse JSON data from a file-like object and convert it into a Python object. This method reads JSON content directly from files, such as .json files, and transforms the structured data ...
๐ŸŒ
Coddy.Tech
coddy.tech โ€บ learn โ€บ courses โ€บ python json โ€บ json.loads()
json.loads() โ€“ Python JSON | Coddy
September 11, 2024 - The function takes a JSON-formatted string as input and returns a corresponding Python object. ... import json json_string = '{"name": "John", "age": 30, "city": "New York"}' parsed_data = json.loads(json_string) print(type(parsed_data)) # Output: ...
๐ŸŒ
The Hitchhiker's Guide to Python
docs.python-guide.org โ€บ scenarios โ€บ json
JSON โ€” The Hitchhiker's Guide to Python
import json parsed_json = json.loads(json_string) and can now be used as a normal dictionary: print(parsed_json['first_name']) "Guido" You can also convert the following to JSON: d = { 'first_name': 'Guido', 'second_name': 'Rossum', 'titles': ['BDFL', 'Developer'], } print(json.dumps(d)) '{"first_name": "Guido", "last_name": "Rossum", "titles": ["BDFL", "Developer"]}' This opinionated guide exists to provide both novice and expert Python developers a best practice handbook to the installation, configuration, and usage of Python on a daily basis.
๐ŸŒ
freeCodeCamp
freecodecamp.org โ€บ news โ€บ how-to-use-the-json-module-in-python
How to Use the JSON Module in Python โ€“ A Beginner's Guide
June 5, 2023 - In this section, you will learn how to use the json.load() function to retrieve JSON data from a file and work with it in your Python programs.
๐ŸŒ
Beautiful Soup
tedboy.github.io โ€บ python_stdlib โ€บ generated โ€บ generated โ€บ json.load.html
json.load() โ€” Python Standard Library
json.load(fp, encoding=None, cls=None, object_hook=None, parse_float=None, parse_int=None, parse_constant=None, object_pairs_hook=None, **kw)[source]ยถ ยท Deserialize fp (a .read()-supporting file-like object containing a JSON document) to a Python object. If the contents of fp is encoded with an ASCII based encoding other than utf-8 (e.g.
Find elsewhere
๐ŸŒ
Readthedocs
simplejson.readthedocs.io
simplejson โ€” JSON encoder and decoder โ€” simplejson 3.19.1 documentation
It does not stop at the end of the first valid JSON document it finds and it will raise an error if there is anything other than whitespace after the document. Except for files containing only one JSON document, it is recommended to use loads(). ... In Python 2, str is considered to be bytes ...
๐ŸŒ
Bogotobogo
bogotobogo.com โ€บ python โ€บ python-json-dumps-loads-file-read-write.php
Python Tutorial: json.dump(s) & json.load(s) - 2024
Now that the file is written. Let's reads it back and decoding the JSON-encoded string back into a Python dictionary data structure: # reads it back with open("4forces.json","r") as f: data = f.read() # decoding the JSON to dictionay d = json.loads(data)
๐ŸŒ
Guru99
guru99.com โ€บ home โ€บ python โ€บ python json: encode(dumps), decode(loads) & read json file
Python JSON: Encode(dumps), Decode(loads) & Read JSON File
July 11, 2026 - import json #File I/O Open function for read data from JSON File data = {} #Define Empty Dictionary Object try: with open('json_file_name.json') as file_object: data = json.load(file_object) except ValueError: print("Bad JSON file format, Change JSON File") JSON Data Interchange Format (RFC โ€“ Request For Comments) doesnโ€™t allow Infinite or Nan Value but there is no restriction in Python- JSON Library to perform Infinite and Nan Value related operation.
๐ŸŒ
Imperial College London
python.pages.doc.ic.ac.uk โ€บ java โ€บ lessons โ€บ java โ€บ 10-files โ€บ 03-load.html
Python for Java Programmers > Loading JSON files | Department of Computing | Imperial College London
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'} ...
๐ŸŒ
PYnative
pynative.com โ€บ home โ€บ python โ€บ json โ€บ python json parsing using json.load() and loads()
Python JSON Parsing using json.load() and loads()
May 14, 2021 - Understand use of json.loads() and load() to parse JSON. Read JSON encoded data from a file or string and convert it into Python dict
Top answer
1 of 6
311

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.

๐ŸŒ
Note.nkmk.me
note.nkmk.me โ€บ home โ€บ python
Load, Parse, Serialize JSON Files and Strings in Python | note.nkmk.me
August 6, 2023 - It is included in the standard library, so no additional installation is necessary. ... You can use json.loads() to convert JSON-formatted strings into Python objects, such as dictionaries.
๐ŸŒ
Programiz
programiz.com โ€บ python-programming โ€บ json
Python JSON: Read, Write, Parse JSON (With Examples)
To work with JSON (string, or file containing JSON object), you can use Python's json module. You need to import the module before you can use it. ... The json module makes it easy to parse JSON strings and files containing JSON object. You can parse a JSON string using json.loads() method.
๐ŸŒ
JSON Lint
jsonlint.com โ€บ learn โ€บ read and write json files in python: load, loads, dump, and dumps
Read and Write JSON Files in Python: load, loads, dump, and dumps | JSONLint
1 month ago - Python's built-in json module reads JSON files and strings without an additional package. Use json.load() for a file, json.loads() for a string, json.dump() to write a file, and json.dumps() to create a string.
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ python โ€บ json-load-in-python
json.load() in Python - GeeksforGeeks
April 3, 2026 - Return Type: Returns a Python object (dict, list, etc.) representing the JSON data. Example 1: This example reads the company name and year from the JSON file. It shows how to access a key-value pairs. ... Explanation: d['company'] and d['year'] access top-level keys from the dictionary returned by json.load(f).
๐ŸŒ
Readthedocs
python-rapidjson.readthedocs.io โ€บ en โ€บ latest โ€บ loads.html
loads() function โ€” python-rapidjson 1.17 documentation
rapidjson.loads(string, *, object_hook=None, number_mode=None, datetime_mode=None, uuid_mode=None, parse_mode=None, allow_nan=True)ยถ ยท Decode the given JSON formatted value into Python object.