Closed jiaola closed 4 years ago
Why is this something a client needs to do at all? From RFC7159, it’s illegal for, JSON data to include a BOM.
Good point! Let me talk with @hsolbrig about this. I wasn't aware that BOM is illegal in JSON. I'll close this PR.
We'll fix the emitter.
That said, it would be handy emit a warning or error that says something a we bit more descriptive than "bad character"? My hunch is that we're not the only ones that will encounter this problem and I suspect that a goodly number of JSON users may never have heard of byte-ordering marks.
Is there a site out there that tells folks how to fix this problem in their language of choice? If not, should we add one to the best practices site?
There’s a good page here: https://www.w3.org/International/questions/qa-byte-order-mark
The RFC I cited shows how it’s inappropriate for application/json, and this JSON-LD
On the playground the BOM files were getting parsed. So the XHR loader or browser XHR itself is handling it. Node loader not so much. A "bad character" error isn't wrong, but worth considering also doing a BOM check and making that particular error more clear. Also a future documentLoader implementation could have a BOM check/ignore option for those who want it.
Indirectly related to #358. When the context file contains a BOM character, there's an error:
This PR fixes it.