The standard return value from the Google maps API looks like this - after conversion from bytes to a string:
b'{\n "destination_addresses" : [ "Washington, DC, USA" ],\n "origin_addresses" : [ "New York, NY, USA" ],\n "rows" : [\n {\n "elements" : [\n {\n "distance" : {\n "text" : "370 km",\n "value" : 369720\n },\n "duration" : {\n "text" : "3 hours 48 mins",\n "value" : 13672\n },\n "status" : "OK"\n }\n ]\n }\n ],\n "status" : "OK"\n}\n'
In order to process is any further, I would like to remove all the line break characters first. However, I don't know how to do it
results_str.replace('\n', "")
won't work, .i.e., it returns the same string without replacing the '\n's, because of the line continuation character.
Same thing happens when I double the backslash
results_str.replace('\\n', "")
Any tips?