Get data from the URL and then call json.loads e.g.
Python3 example:
import urllib.request, json
with urllib.request.urlopen("http://maps.googleapis.com/maps/api/geocode/json?address=google") as url:
data = json.loads(url.read().decode())
print(data)
Python2 example:
import urllib, json
url = "http://maps.googleapis.com/maps/api/geocode/json?address=google"
response = urllib.urlopen(url)
data = json.loads(response.read())
print data
The output would result in something like this:
{
"results" : [
{
"address_components" : [
{
"long_name" : "Charleston and Huff",
"short_name" : "Charleston and Huff",
"types" : [ "establishment", "point_of_interest" ]
},
{
"long_name" : "Mountain View",
"short_name" : "Mountain View",
"types" : [ "locality", "political" ]
},
{
...
Answer from Anurag Uniyal on Stack Overflow Top answer 1 of 10
452
Get data from the URL and then call json.loads e.g.
Python3 example:
import urllib.request, json
with urllib.request.urlopen("http://maps.googleapis.com/maps/api/geocode/json?address=google") as url:
data = json.loads(url.read().decode())
print(data)
Python2 example:
import urllib, json
url = "http://maps.googleapis.com/maps/api/geocode/json?address=google"
response = urllib.urlopen(url)
data = json.loads(response.read())
print data
The output would result in something like this:
{
"results" : [
{
"address_components" : [
{
"long_name" : "Charleston and Huff",
"short_name" : "Charleston and Huff",
"types" : [ "establishment", "point_of_interest" ]
},
{
"long_name" : "Mountain View",
"short_name" : "Mountain View",
"types" : [ "locality", "political" ]
},
{
...
2 of 10
165
I'll take a guess that you actually want to get data from the URL:
jsonurl = urlopen(url)
text = json.loads(jsonurl.read()) # <-- read from it
Or, check out JSON decoder in the requests library.
import requests
r = requests.get('someurl')
print r.json() # if response type was set to JSON, then you'll automatically have a JSON response here...
GeeksforGeeks
geeksforgeeks.org › python › how-to-read-a-json-response-from-a-link-in-python
How to read a JSON response from a link in Python? - GeeksforGeeks
July 23, 2025 - This library helps to open the URL and read the JSON response from the web. To use this library in python and fetch JSON response we have to import the json and urllib in our code, The json.loads() method returns JSON object. Below is the process by which we can read the JSON response from a link ...
Videos
Real Python
realpython.com › python-json
Working With JSON Data in Python – Real Python
August 20, 2025 - If you followed along with the tutorial, then you’ve got a hello_frieda.json file that doesn’t contain newlines or indentation. Alternatively, you can download hello_frieda.json in the materials by clicking the link below: Free Bonus: Click here to download the free sample code that shows you how to work with JSON data in Python.
Stack Abuse
stackabuse.com › how-to-get-json-from-a-url-in-python
How to Get JSON from a URL in Python
February 14, 2025 - We used the get() method to fetch JSON data from the URL https://jsonplaceholder.typicode.com/posts, we extracted the JSON data using the json() method, and printed it to the console. And that's pretty much it! You will get the JSON response stored as a Python list, with each post represented ...
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 - As you can see in the example, executing the json.tool module with the input file path formats the JSON data and displays the formatted output on the console. You can also redirect the formatted output to an output file by specifying the output file name as the second argument: python -m json.tool horoscope_data.json formatted_data.json
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.
ReqBin
reqbin.com › code › python › rituxo3j › python-requests-json-example
How do I get JSON using the Python Requests?
In this Python GET JSON example, we send a GET request to the ReqBin echo URL and receive JSON data in the response. The custom 'Accept: application/json' header tells the server that the client expects a JSON.
Python Basics
pythonbasics.org › json
Working With JSON Data in Python - Python Tutorial
Interacting with the web is mostly done through APIs (Application Programmable Interface), in JSON format. Related course: Complete Python Programming Course & Exercises
ReqBin
reqbin.com › req › python › 5nqtoxbx › get-json-example
Python | How to get JSON from URL?
The server informs the Python client that it has returned JSON with a Content-Type: application/json response header. In this Python JSON from URL example, we make a GET request to the ReqBin echo URL to get the JSON.
GitHub
gist.github.com › sirleech › 2660189
Python Read JSON from HTTP Request of URL · GitHub
Python Read JSON from HTTP Request of URL · Raw · gistfile1.py · This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters · Show hidden characters · Copy link · This is very helpful. Thank you. Copy link · Thanks, i use your first example.
DataCamp
datacamp.com › tutorial › json-data-python
Python JSON Data: A Guide With Examples | DataCamp
December 3, 2024 - This function is used to serialize a Python object into a JSON string. The dumps() function takes a single argument, the Python object, and returns a JSON string. Here's an example:
Power CMS Technology
powercms.in › article › how-get-json-data-remote-url-python-script
How to get json data from remote url into Python script | Power CMS Technology
August 17, 2016 - import urllib, json url = "http://maps.googleapis.com/maps/api/geocode/json?address=googleplex&sensor=false" response = urllib.urlopen(url) data = json.loads(response.read()) print data
freeCodeCamp
freecodecamp.org › news › how-to-parse-json-in-python-with-examples
How to Parse JSON in Python – A Complete Guide With Examples
October 29, 2025 - JSON arrays represent ordered lists of values and appear frequently in API responses when returning collections of items. Python converts JSON arrays into lists, which you can iterate through or access by index. Here's an example parsing a list of products from an inventory system: