json.load loads from a file-like object. You either want to use json.loads:

json.loads(data)

Or just use json.load on the request, which is a file-like object:

json.load(request)

Also, if you use the requests library, you can just do:

import requests

json = requests.get(url).json()
Answer from Blender on Stack Overflow
🌐
W3Schools
w3schools.com › python › python_json.asp
Python JSON
If you have a Python object, you can convert it into a JSON string by using the json.dumps() method.
🌐
Python
docs.python.org › 3 › library › json.html
json — JSON encoder and decoder
2 weeks ago - Decode a JSON document from s (a str beginning with a JSON document) and return a 2-tuple of the Python representation and the index in s where the document ended. This can be used to decode a JSON document from a string that may have extraneous data at the end.
Discussions

Convert string to JSON in Python? - Stack Overflow
I'm trying to convert a string, generated from an http request with urllib3. Traceback (most recent call last): File " ", line 1, in data = json.load(data) ... More on stackoverflow.com
🌐 stackoverflow.com
converting JSON to string in Python - Stack Overflow
I did not explain my questions clearly at beginning. Try to use str() and json.dumps() when converting JSON to string in python. More on stackoverflow.com
🌐 stackoverflow.com
How to turn JSON into objects in python?
It's easier (and probably better) if you define the class first. Then, turn the json into a dict, then into an instance of that class. import json class Person: def __init__(self, name, job): self.name = name self.job = job person_json = '''{ "name":"Harry", "job":"Mechanic" }''' person_dict = json.loads(person_json) person = Person(**person_dict) Edit: Sorry I didn't answer your exact question. But maybe that was still helpful. There's also attrdict . Making a whole class from a dict is certainly possible, but not something most people would want to do. And when you say "yield", do you mean you want the Person definition as Python code, or the Person class object? More on reddit.com
🌐 r/learnpython
8
2
September 2, 2021
There's no way to have multi-line strings in a Json file, right? How could I deal with this limitation when getting Python to read from such a file.
you can have multiline strings in json. this is the contents of sample.json {"text": "hello world\n2nd line"} and some python that reads the file import json with open("/tmp/sample.json", "rb") as f: x = json.loads(f.read()) the value of x["text"] is a multiline string. More on reddit.com
🌐 r/learnpython
9
5
September 13, 2017
🌐
freeCodeCamp
freecodecamp.org › news › python-json-how-to-convert-a-string-to-json
Python JSON – How to Convert a String to JSON
November 9, 2021 - you can turn it into JSON in Python using the json.loads() function. The json.loads() function accepts as input a valid string and converts it to a Python dictionary.
🌐
Real Python
realpython.com › python-json
Working With JSON Data in Python – Real Python
August 20, 2025 - JSON, or JavaScript Object Notation, is a widely-used text-based format for data interchange. Its syntax resembles Python dictionaries but with some differences, such as using only double quotes for strings and lowercase for Boolean values. With built-in tools for validating syntax and manipulating ...
🌐
Scaler
scaler.com › home › topics › string to json python
Convert String to JSON in Python - Scaler Topics
December 4, 2023 - This function accepts a Python object and produces a JSON string as its output. Decoding (deserializing) JSON: To change a JSON string into a Python object, the json.loads() function is used.
🌐
Analytics Vidhya
analyticsvidhya.com › home › ways to convert string to json object
Ways to Convert String to JSON Object
March 21, 2024 - In such cases, json.loads() remains the preferred choice due to its broader support for handling JSON structures. The eval() function in Python can also be utilized to convert a string to a JSON object.
Find elsewhere
🌐
GeeksforGeeks
geeksforgeeks.org › python › python-ways-to-convert-string-to-json-object
Convert String to JSON Object - Python - GeeksforGeeks
Let's explore different methods to do this efficiently. json.loads() method is the most commonly used function for parsing a JSON string and converting it into a Python dictionary.
Published   July 11, 2025
🌐
Spark By {Examples}
sparkbyexamples.com › home › python › convert json object to string in python
Convert JSON Object to String in Python - Spark By {Examples}
May 21, 2024 - Example 1: Let’s have a python dictionary with country details and convert this into json string. import json # Dictionary object representing as JSON country_json = { "Country Name": "US","States": ["California", "Texas","Ohio"],"Lakes_Available":"Yes"} # Json to string - Using json.dumps() country_string = json.dumps(country_json) print(country_string) print(type(country_string)) # Output: # {"Country Name": "US", "States": ["California", "Texas", "Ohio"], "Lakes_Available": "Yes"} #
🌐
KDnuggets
kdnuggets.com › convert-python-dict-to-json-a-tutorial-for-beginners
Convert Python Dict to JSON: A Tutorial for Beginners - KDnuggets
To convert a Python dictionary to JSON string, you can use the dumps() function from the json module. The dumps() function takes in a Python object and returns the JSON string representation.
🌐
GeeksforGeeks
geeksforgeeks.org › python › python-convert-json-to-string
Convert JSON to string - Python - GeeksforGeeks
July 12, 2025 - This code creates a Python dictionary and converts it into a JSON string using json.dumps(). The result is printed along with its type, confirming that the output is now a string. ... import json # create a sample json a = {"name" : "GeeksforGeeks", "Topic" : "Json to String", "Method": 1} y = json.dumps(a) print(y) print(type(y))
Top answer
1 of 2
201

json.dumps() is much more than just making a string out of a Python object, it would always produce a valid JSON string (assuming everything inside the object is serializable) following the Type Conversion Table.

For instance, if one of the values is None, the str() would produce an invalid JSON which cannot be loaded:

>>> data = {'jsonKey': None}
>>> str(data)
"{'jsonKey': None}"
>>> json.loads(str(data))
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/json/__init__.py", line 338, in loads
    return _default_decoder.decode(s)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/json/decoder.py", line 366, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/json/decoder.py", line 382, in raw_decode
    obj, end = self.scan_once(s, idx)
ValueError: Expecting property name: line 1 column 2 (char 1)

But the dumps() would convert None into null making a valid JSON string that can be loaded:

>>> import json
>>> data = {'jsonKey': None}
>>> json.dumps(data)
'{"jsonKey": null}'
>>> json.loads(json.dumps(data))
{u'jsonKey': None}
2 of 2
2

There are other differences. For instance, {'time': datetime.now()} cannot be serialized to JSON, but can be converted to string. You should use one of these tools depending on the purpose (i.e. will the result later be decoded).

🌐
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
🌐
EDUCBA
educba.com › home › software development › software development tutorials › python tutorial › python json to string
Python JSON to string | Working & examples of Python JSON to string
April 3, 2023 - In this article, we use json module to deal with JSON data, and we also use the dumps() function, which takes JSON data and converts it into the string format. We also can fetch JSON data directly through the website using the requests module in Python with get() function. This is a guide to Python JSON to string.
Address   Unit no. 202, Jay Antariksh Bldg, Makwana Road, Marol, Andheri (East),, 400059, Mumbai
🌐
Medium
medium.com › @blogshub4 › how-to-pretty-print-a-json-string-in-python-98a85f99ecb4
How to Pretty Print a JSON String in Python | by Blogshub | Medium
December 22, 2024 - Pretty Print JSON with Indentation: Use the json.dumps() method to convert the Python object back into a JSON string, and specify the indent parameter to define the level of indentation for readability.
🌐
W3Schools
w3schools.com › python › gloss_python_json_parse.asp
Python JSON Parse
If you have a JSON string, you can parse it by using the json.loads() method. 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 ...
🌐
GeeksforGeeks
geeksforgeeks.org › python › python-json
Python JSON - GeeksforGeeks
December 23, 2025 - You can parse JSON data in Python to access or manipulate it, convert dictionaries to JSON strings, and transform JSON strings back into Python objects.
🌐
DigitalOcean
digitalocean.com › community › tutorials › python-pretty-print-json
How to Pretty Print JSON in Python | DigitalOcean
September 16, 2025 - Serialize custom Python objects that are not natively supported by creating a JSONEncoder subclass or by passing a handler function to the default parameter. Process massive JSON files without exhausting memory by using streaming parsers like ijson or adopting the line-delimited JSON format. Boost performance in data-intensive applications by replacing the standard json module with faster alternatives like orjson. Reconstruct your custom Python objects from a JSON string by using the object_hook parameter in json.loads() to intercept and transform the data.
🌐
iProyal
iproyal.com › blog › python-string-to-json
How to Convert a Python String to JSON (Beginner’s Guide)
August 29, 2025 - Use `json.dumps()` to serialize a Python object into a JSON string.