C++ Logo


Advanced search

Re: [SG16-Unicode] BOM in JSON (was: Re: SG16 meeting summary for July 31st, 2019)

From: Henri Sivonen <hsivonen_at_[hidden]>
Date: Mon, 19 Aug 2019 22:25:05 +0300
On Mon, Aug 19, 2019 at 9:57 PM Ben Boeckel <ben.boeckel_at_[hidden]> wrote:
> On Mon, Aug 19, 2019 at 21:36:38 +0300, Henri Sivonen wrote:
> > Presumably the reason to use JSON instead of a custom format is to make the
> > format consumable with JSON libraries.
> Yes.
> > Therefore, it makes sense for it not
> > to profile JSON but to work with off-the-shelf libraries. I haven't
> > actually surveyed JSON libraries for UTF-8 BOM acceptance, but there are
> > three reasons why UTF-8 BOM acceptance makes sense for a general-purpose
> > JSON parsing library:
> Presumably no (widely-usable) JSON library *requires* a BOM though to
> parse properly.

Presumably, but, as noted, I haven't actually surveyed them.

> > 1. Compatibility with Windows-ish text editors for those JSON formats that
> > _are_ edited with text editors.
> Notepad?

Yes, Notepad. It's generally easier to make parsers of all kinds (XML
before, JSON later) accept the UTF-8 BOM than to fight Notepad. It'll
take a long time for the existing installed base to get replaced with
the newest: https://mobile.twitter.com/JenMsft/status/1163474010509701120

> > 2. Consistency with Web browsers.
> I don't see why a web browser would care about these files.

Maybe not _these_ JSON files, but a general-purpose JSON parser can
still care about consistency with Web browsers.

Henri Sivonen

Received on 2019-08-19 21:25:20