Currently, I am using the code below to load a JSON file. However, I want to load the JSON data without saving a file to my laptop. I tried directly to load however it is giving me an error.
First Code:
url = "example.url"
response = requests.request("GET", url, headers=headers)
with open('save.json', 'wb') as outf:
outf.write(response.content)
file = open("save.json")
data = json.load(file)
Code Tried:
url = "example.url"
response = requests.request("GET", url, headers=headers)
data = json.load(response.content)
Error:
AttributeError: 'bytes' object has no attribute 'read'