#Debugging JSON SyntaxError: Unexpected token .

6 messages · Page 1 of 1 (latest)

wintry marlin
#

I am after a way to see which characters are causing the JSON.parse call to fail with this error. If I can find out which characters are wrong I can try figure out why it's happening.

regal bone
#

It tells you the position of the character

wintry marlin
#

yeah, not really helpful

#

i think the problem i'm facing is my sequence of bytes only makes sense if you decode it as utf8 but im not sure how to address that in js

wintry marlin
#

i figured it out. needed to call new TextDecoder().decode(bytes) and then i can parse it just fine

regal bone
#

Where do these bytes come from?