I am making a REST api call with Requests library.
response = requests.get("https://urltomaketheapicall", headers={'authorization': 'bearer {0}'.format("7777777777777777777777777777")}, timeout=5)
When I do response.json()
I get a key with these values
{'devices': '....iPhone\xa05S, iPhone\xa06, iPhone\xa06\xa0Plus, iPhone\xa06S'}
When I do print(response.encoding)
I get None
When I do print(type(data[devices]))
I get <class 'str'>
If i do print(data[devices])
I get '....iPhone 5S, iPhone 6, iPhone 6 Plus, iPhone 6S'
without the special characters.
Now if do
new_dict={}
new_val = data[devices]
new_dict["devices"] = new_val
print(new_dict["devices"])
I will get the special characters in the new dictionary as well.
Any ideas?
I want to get rid of the special characters since I need to read these json and put it in a pyspark dataframe and with those characters i get a _corrupted_record
rd= spark.sparkContext.parallelize([data])
df = spark.read.json(rd)
I want to avoid solutions like .replace("\\xa0"," ")