You are here : python_3requestsrjson

r.json() - requests

r.json() is used to decode JSON Data in case the response is json data.

In case the JSON decoding fails, r.json raises an exception. For example, if the response gets a 204 (No Content), or if the response contains invalid JSON, attempting r.json raises ValueError: No JSONobject could be decoded.


Syntax

r=requests.get(url)
r.json()


Example

import requests
r=requests.get('http://api.duckduckgo.com/?q=valley+forge+national+park&format=json&pretty=1')
data=r.json()		#data is JSON Data


Output / Return Value

JSON Data.


Limitations


Alternatives / See Also


Reference