python - Replace \b in json -


i'm receiving json file begins : 'b\'{ "key" : .... i'm attempting remove 'b\' part of string it's not valid json.

the json read using :

import urllib.request link = "http://www...." urllib.request.urlopen(link) url:     s = str(url.read()) 

my code replace : replace('\'b\'', '') string 'b\'{ "key" : .... remains instead of { "key" : ....

attempting recreate issue excluding json string :

mystr = ' b\'{  ' mystr.replace(' b\'{ ', '')  

successfully replaces ' ' output.

you adding b calling str() on data get. don't that.

if need convert string, should decode instead:

s = url.read().decode('utf-8') 

but in fact can pass bytestring directly json.loads().


Comments

Popular posts from this blog

neo4j - finding mutual friends in a cypher statement starting with three or more persons -

php - How to remove letter in front of the word laravel -

minify - Minimizing css files -