question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

"Unexpected token" for JSON files with non-UTF-8 encoding

See original GitHub issue

Some songs can’t be previewed and display an error:

Uncaught SyntaxError: Unexpected token � in JSON at position 0
    at JSON.parse (<anonymous>)
    at ZipLoader.extractAsJSON (build.js:274)
    at Object.keys.forEach.filename (build.js:96)
    at Array.forEach (<anonymous>)
    at ZipLoader.loader.on (build.js:96)
    at ZipLoader.dispatch (build.js:274)
    at XMLHttpRequest.xhr.onload (build.js:274)

This is due to non-UTF-8 encoding in .json files (checked with Notepad++).

Examples of UCS-2 LE BOM in info.json:

  1. https://supermedium.com/beatsaver-viewer/?id=5239-4638
  2. https://supermedium.com/beatsaver-viewer/?id=10606-11164
  3. https://supermedium.com/beatsaver-viewer/?id=10880-11495

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
ngokevincommented, Jan 30, 2019

We can’t live without kpop!

1reaction
ngokevincommented, Jan 13, 2019

Thanks, I had some code to normalize it, I’ll add it later.

Read more comments on GitHub >

github_iconTop Results From Across the Web

757: unexpected token a t '{ (JSON::ParserError)
I'm getting a ParserError when running a Ruby script which generates translated HTML files from a JSON file. The encoding of the JSON...
Read more >
Bug when parsing JSON in superagent/lib/node/parsers/json.js
When I open the stacktrace : { SyntaxError: Unexpected token  in JSON at posit... ... It may also be caused by use...
Read more >
How to Remove Non UTF-8 Characters From a File - Baeldung
Learn how to detect and remove non-UTF-8 characters from a file. ... Trunctated #### Uncaught SyntaxError: Unexpected identifier
Read more >
How to fix Unexpected Token in JSON error (for ... - YouTube
Not a programmer? Read this! ** - If you get this error in an app you didn't make, and/or you're not a web...
Read more >
encoding/xml - Go Packages
Unmarshal parses the XML-encoded data and stores the result in the value ... if Token encounters an unexpected end element or EOF before...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found