ietf
[Top] [All Lists]

Re: [Json] BOMs

2013-11-20 10:35:41

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


<Prev in Thread] Current Thread [Next in Thread>