Strict variant that allows non-Object/Array top level types
GoogleCodeExporter opened this issue · 3 comments
GoogleCodeExporter commented
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
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
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
GoogleCodeExporter commented
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