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.
Discussions

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
Parsing a string representing json to json, but some string values contain double quotes
unless reddit is eating a backslash that i'm missing json = """ { "key" : "This is a \\"test\\"" } """ then if you're unfortunate to have no backslashes, then it's invalid json and a json parser won't be able to read it, you'll need to fix the data first before parsing it you might be able to make some educated guesses based on the expectations of the data itself (like everything between " : " and " } is a string and you can replace all quotes " with backslashed quotes \") - first sanitize it and then let a json parser do it's normal job on it but otherwise there's no way to generically fix this for all possible inputs More on reddit.com
🌐 r/learnpython
22
1
December 1, 2023
json.load converting double quotes to single quotes

Python displays strings as single-quoted. So in the interpreter:

>>> "dog"
'dog'
>>> str(123)
'123'

If you mean how to format it properly to serve json upon a GET request, you can transform python data back into a json string with json.dumps(data).

More on reddit.com
🌐 r/learnpython
7
4
April 7, 2014
🌐
GeeksforGeeks
geeksforgeeks.org › python › python-json
Python JSON - GeeksforGeeks
December 23, 2025 - Let's see an example where we convert Python objects to JSON objects. Here json.dumps() function will convert a subset of Python objects into a JSON string.
🌐
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
🌐
DigitalOcean
digitalocean.com › community › tutorials › python-pretty-print-json
How to Pretty Print JSON in Python | DigitalOcean
September 16, 2025 - The json.dumps() method takes the JSON object and returns a JSON formatted string. The indent parameter defines the indent level for the formatted string. Let’s see what happens when we try to print a JSON file data.
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 - Using the json.loads() method, we can deserialize native String, byte, or bytearray instance containing a JSON document to a Python dictionary.
Find elsewhere
🌐
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.
🌐
Python
docs.python.org › 3 › library › json.html
json — JSON encoder and decoder
3 weeks ago - For the most compact JSON, specify (',', ':') to eliminate whitespace. default (callable | None) – A function that is called for objects that can’t otherwise be serialized. It should return a JSON encodable version of the object or raise a TypeError. If None (the default), TypeError is raised. sort_keys (bool) – If True, dictionaries will be outputted sorted by key. Default False. Changed in version 3.2: Allow strings for indent in addition to integers.
🌐
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))
🌐
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.
🌐
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 - While literal_eval() offers security benefits, it may not be suitable for all scenarios, especially when dealing with complex JSON data. 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.
🌐
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"} #
🌐
Real Python
realpython.com › python-json
Working With JSON Data in Python – Real Python
August 20, 2025 - A key-value pair in a JSON object is separated by a colon (:). On the left side of the colon, you define a key. A key is a string you must wrap in double quotes ("). Unlike Python, JSON strings don’t support single quotes ('). The values in a JSON document are limited to the following data types:
🌐
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 ...
🌐
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
🌐
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.