I have searched for a solution regarding this issue and I have not found one that I can understand. I am new to Python and need basic help understanding why I get the error message: TypeError: is not JSON serializable.
import requests
import json
r = requests.get("http://api.bls.gov/publicAPI/v2/timeseries/data/LAUCN040010000000005")
with open("C:\...MyPath...\Output.txt", "w") as outfile:
json.dumps(r, outfile)
This is my simple code I am testing. I appreciate the help.
ris not a JSON object; you can'tdumpssomething that isn't json. You can, however, first parse the bls string to a JSON object and then dumps it. I don't see much sense in that, though.