shau-lok / google-gson

Automatically exported from code.google.com/p/google-gson

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Strict variant that allows non-Object/Array top level types

GoogleCodeExporter opened this issue · comments

The latest Ecmascript standard (which modern browsers adhere to) follows RFC 
4627 strictly, with the one exception that the top-level type can be any type, 
not just Object or Array. It would be nice to have a Gson parsing mode that has 
the same behavior.

http://www.ecma-international.org/publications/files/ECMA-ST/ECMA-262%20edition%
205.1,%20June%202011.pdf

Original issue reported on code.google.com by chr...@google.com on 21 Dec 2011 at 6:51

You can use setLenient(true) to enable this. Unfortunately this also disables 
other strictness checks.

Original comment by jessewil...@google.com on 21 Dec 2011 at 6:23

One more option, while I'm thinking of it. You can wrap your document in '[' 
and ']' to make it conform to the strict standard.

Original comment by limpbizkit on 21 Dec 2011 at 6:30

  • Changed state: WontFix
To check whether something is valid JSON as per Ecmascript would then require 
catching a MalformedJsonException, wrapping in '[' + json + ']', and trying 
again? I don't think that is reasonable.

Original comment by chr...@google.com on 21 Dec 2011 at 6:38