Handling a BOM with .json()
See original GitHub issueAnybody know how I should be handling a BOM with a returned json payload? Right now i’m getting this error when calling res.json()
Exception: FetchError: invalid json response body at https://api_that_returns_json_with_bom reason: Unexpected token ? in JSON at position 0
I tried adding an Accept header of application/json; charset=utf-8
but that didn’t resolve the issue.
Issue Analytics
- State:
- Created 5 years ago
- Comments:7
Top Results From Across the Web
The Curious Case of the JSON BOM - Jimmy Bogard
1. Bind the parameter type as 'string' instead of 'SaySomething' to get the raw values and avoid JSON deserialization, or 2. Change the...
Read more >JSON Specification and usage of BOM/charset-encoding
You are right. The BOM character is illegal in JSON (and not needed); The MIME charset is illegal in JSON (and not needed...
Read more >Handling a BOM with .json() · Issue #541 · node-fetch ... - GitHub
Anybody know how I should be handling a BOM with a returned json payload? Right now i'm getting this error when calling res.json()...
Read more >Unicode Character problems in JSON and playing with BOM ...
Here we go! Let's start our article with a question. Is it enough to set “application / json; charset = utf-8” as the...
Read more >Python : How to fix Unexpected UTF-8 BOM error when using ...
If the json.loads() method throws an Unexpected UTF-8 BOM error, it is due to a BOM value being present in the stream or...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
🎉 This issue has been resolved in version 3.2.3 🎉
The release is available on:
Your semantic-release bot 📦🚀
Hmm, chrome seems to be able to decode BOM
What we are essentially doing is:
We should stop using buffer and turn towards using TextDecoder instead, this removes the BOM
While we are at it: