-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Closed
Labels
Description
As noted in the documentation for JsonReader.setLenient
, there are a number of areas where Gson accepts JSON inputs that are not strictly conformant, even when lenient mode is off:
- JsonReader allows the literals
true
,false
andnull
to have any capitalization, for examplefAlSe
- JsonReader supports the escape sequence
\'
, representing a'
- JsonReader supports the escape sequence
\LF
(withLF
being the Unicode character U+000A), resulting in a LF within the read JSON string- JsonReader allows unescaped control characters (U+0000 through U+001F)
To which we could add that it allows a trailing comma in JSON arrays, for example ["foo", "bar",]
as noted in #494.
We could imagine that GsonBuilder
would acquire a method setStrict()
, mutually exclusive with setLenient()
and that JsonReader
would likewise acquire setStrict(boolean)
and isStrict()
. We can't make strict mode the default, for fear of breaking existing users, but we could recommend it.
mitasov-ra and Drevoed