I want to remove the u
(unicode value) from the results. Other tools is not reading it in JSON format.
import requests
import json
headers={
"accept": "application/json",
"content-type": "application/json"
}
test_urls = ['https://google.com']
def return_json(url):
try:
response = requests.get(url,headers=headers)
# Consider any status other than 2xx an error
if not response.status_code // 100 == 2:
return "Error: Unexpected response {}".format(response)
json_obj = response.json()
return json_obj
except requests.exceptions.RequestException as e:
# A serious problem happened, like an SSLError or InvalidURL
return "Error: {}".format(e)
for url in test_urls:
print "Fetching URL '{}'".format(url)
print return_json(url)
Results:
{u'rows': [{u'timestamp': 1585924500001L, u'RAM_': 1000, u'Allocated': 4000.78, u'queue': 0, u'Details': u'Connected': 2, u'Queue': 0, u'EventsQueue': 0}]
I want results without u
in the value