(Feb-25-2020, 04:11 PM)jk91 Wrote: "category” what should it be in a correct way then it might be deliberately so that it hould be a very complex case isn't it?Sure it can have be placed there deliberately,so you shall clean it up.
You have given little info about the task,and all of this Thread is mostly been trying for you to open a working
json
file.Alone it will be SyntaxError
>>> s = "category” File "<interactive input>", line 1 s = "category” ^ SyntaxError: EOL while scanning string literalReading it with
json.load
it will be JSONDecodeError
.So have to read file in a normal way so it's string output an clean it up before it's a working
json
file.The cleaning up would be like this.
>>> s = '"category”' >>> s '"category”' >>> s1 = s.replace('”', '"') >>> s1 '"category"'So if i mess up
data.json
with ”
,i would clean it up like this.>>> with open('data.json', encoding='utf-8') as f: ... file_content = f.read() >>> fix = file_content.replace('”', '"') >>> with open('fixed.json', 'w', encoding='utf-8') as f_out: ... f_out.write(fix)