Telegram parse error
Error parsing file "result.json":
JSON.parse: bad escaped character at line 33 column 17 of the JSON data
Solution: I exported from telegram group history (129mb) in result.json, then replaced some bad characters with python:
with open('result.json', encoding='utf-8') as f:
result = f.read()
result = result.replace('\\x0C','').replace('\\x00','').replace('\\x10','').replace('\\x11','').replace('\\x08','').replace('\\x01','')
with open('r.json','w+', encoding='utf-8') as f:
f.write(result)```
And now it works! Seems like telegram inserts some bad characters into .json
Thank you for huge work!
I don't personally use Telegram so maybe this is a thing that happens in all new exports and I wouldn't know, but in case it isn't it might be useful to have a sample of where this appears in the file. Could you show what is on line 33 of the file?
As @HopperElec said, could you show where in the JSON are these characters? Are those message fields? We can filter them out if the Telegram exporter is generating invalid JSONs (I guess they are not being escaped correctly)
The best way is to escape ALL using script above, cause this characters may appear in unexpected places of exported json
Can you test if your JSON is read by any other known tool (JS's JSON.parse, or any JSON visualizer tool)? We are using a custom implementation and may be bugged.
For example, we are using charCodeAt(i) > 0 which I think is wrong, and may be causing problems with your 0x00 characters.