sinamdar2015 / google-gson

Automatically exported from code.google.com/p/google-gson
0 stars 0 forks source link

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

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
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

GoogleCodeExporter commented 9 years ago
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

GoogleCodeExporter commented 9 years ago
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

GoogleCodeExporter commented 9 years ago
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