I tried to get some data from a Google maps request; it returned the following data. It starts with a 'b' character somehow:
b'{
\n "destination_addresses" : [ "Toronto, ON, Canada" ],
\n "origin_addresses" : [ "Ottawa, ON, Canada" ],
\n "rows" : [\n {
\n "elements" : [\n {
\n "distance" : {
\n "text" : "450 km",
\n "value" : 449678\n
},
\n "duration" : {
\n "text" : "4 hours 14 mins",
\n "value" : 15229\n
},
\n "status" : "OK"\n
}\n ]\n
}\n ],
\n "status" : "OK"\n
}\n'
Then I tried to get a value from the data, it errors because of the 'b' at the beginning. If I remove the 'b', it works fine:
response = str(urllib.request.urlopen(url).read())
result = json.loads(response.replace('\\n', ''))
Is there a way in Python to retrieve the values without removing the 'b'?