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
Working with JSON in Python
Nice article. One minor, super-pedantic nit-pick: you keep using the words "JSON object", when you don't really mean that. A "JSON object" is merely one particular type a JSON string or text can hold, as defined by RFC7159 and its update RFC8259 , ECMA262 , ECMA404 , W3C, and various other standards. So you keep describing how to convert to/from "JSON object", when what you're really doing is converting to/from JSON string (which are also python strings) - and those strings actually are of JSON arrays in your examples, not JSON objects. The arrays happen to contain JSON objects inside the array. So for example this: json.dumps() takes in a Python data type and returns a JSON object. json.loads() takes in a JSON object and returns a Python data type. ...isn't actually true. For example just the two characters 42 is a perfectly valid JSON string, of just a JSON number type. Python's json.dumps() will accept a python int of 42 and convert it to a string. It will then take that serialized python/JSON string and convert it back to a simple python int, using json.loads(). There is no JSON object involved whatsoever. Again, I know I'm being pedantic. And I don't mean to criticize - the article's fine overall. I just get triggered by some minor details sometimes. :) More on reddit.com
๐ŸŒ r/Python
5
2
April 11, 2022
How Do I Get Python to Recognize this JSON string?
You're overriding the json module with a variable, here: json=soup.find_all('script') Call that variable literally anything else and you're golden More on reddit.com
๐ŸŒ r/learnpython
7
1
June 2, 2024
๐ŸŒ
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).

Find elsewhere
๐ŸŒ
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.
๐ŸŒ
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 - This comes built-in to Python and is part of the standard library. So, say you have a file named demo.py. At the top you would add the following line: ... #include json library import json #json string data employee_string = '{"first_name": "Michael", "last_name": "Rodgers", "department": "Marketing"}' #check data type with type() method print(type(employee_string)) #output #<class 'str'>
๐ŸŒ
Oreate AI
oreateai.com โ€บ blog โ€บ from-data-structures-to-strings-unpacking-json-conversion-in-python โ€บ be0b2c0900c33f8aa436ce7752f3aa58
From Data Structures to Strings: Unpacking JSON Conversion in Python - Oreate AI Blog
February 9, 2026 - Learn how to convert Python data structures into JSON strings using the `json.dumps()` function, ensuring compatibility for data exchange and storage.
๐ŸŒ
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 - 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 JSON files, Python makes it straightforward to work with JSON data.
๐ŸŒ
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.
Call ย  +917738666252
Address ย  Unit no. 202, Jay Antariksh Bldg, Makwana Road, Marol, Andheri (East),, 400059, Mumbai