W3C home > Mailing lists > Public > www-tag@w3.org > November 2013

Re: [Json] BOMs

From: Allen Wirfs-Brock <allen@wirfs-brock.com>
Date: Tue, 19 Nov 2013 08:59:36 -0800
Cc: "t.p." <daedulus@btconnect.com>, John Cowan <cowan@mercury.ccil.org>, IETF Discussion <ietf@ietf.org>, Pete Cordell <petejson@codalogic.com>, JSON WG <json@ietf.org>, Anne van Kesteren <annevk@annevk.nl>, www-tag@w3.org, es-discuss <es-discuss@mozilla.org>
Message-Id: <43255615-2FC9-4726-99FD-1B13D6B1F033@wirfs-brock.com>
To: Martin J. Dürst <duerst@it.aoyama.ac.jp>

On Nov 19, 2013, at 3:09 AM, Martin J. Dürst wrote:
> ...
> As for JSON, it doesn't have the problem of legacy encodings. JSON by definition is encoded in an Unicode encoding form, and it's easy to distinguish these because of the restrictions on character sequences in JSON. And this can be done without a BOM (or with a BOM).
> 
> What's most important now is to know what receivers actually accept. We are not in a design phase, we are just updating the definition of JSON and making sure we fix problems if there are problems, but we have to use the installed base for the main guidance, not other protocols or formats.

There can be no doubt that the most widely deployed JSON parsers are those that are built intp the browser javascript implementations.  The ECMAScript 5 specification for JSON.parse that they implement says BOM is an illegal character.  But what do the browser actually implement?  This:

//FireFox 25 scratchpad execution:
JSON.parse('\ufeff {"abc": 0} ')
/*
Exception: JSON.parse: unexpected character
@Scratchpad/1:1
*/

JSON.parse('\ufeff {"abc": 0} ')
/*
Exception: JSON.parse: unexpected character
@Scratchpad/1:1
*/

JSON.parse('\ufeff {"abc": 0} ')
/*
Exception: JSON.parse: unexpected character
@Scratchpad/1:1
*/
JSON.parse('\ufeff {"abc": 0} ')
/*
Exception: JSON.parse: unexpected character
@Scratchpad/1:1
*/
JSON.parse('\ufeff {"abc": 0} ')
/*
Exception: JSON.parse: unexpected character
@Scratchpad/1:1
*/

//Safari 5.1.9 JS console
JSON.parse('\ufeff {"abc": 0} ')
message: "JSON Parse error: Unrecognized token '?'"

//Chrome 31 JS console
JSON.parse('\ufeff {"abc": 0} ')
SyntaxError: Unexpected token 
message: "Unexpected token "

Unfortunately, I don't have access to IE right now,  but the trend is clear

Allen



Received on Tuesday, 19 November 2013 17:00:17 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 22:57:00 UTC