-
Notifications
You must be signed in to change notification settings - Fork 4.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve lenient mode documentation #2122
Improve lenient mode documentation #2122
Conversation
@@ -252,6 +252,9 @@ public final JsonElement toJsonTree(T value) { | |||
* read is strict. Create a {@link JsonReader#setLenient(boolean) lenient} | |||
* {@code JsonReader} and call {@link #read(JsonReader)} for lenient reading. | |||
* | |||
* <p>No exception is thrown if the JSON data has multiple top-level JSON elements, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This behavior is probably rather questionable though...
@@ -304,8 +304,6 @@ public JsonReader(Reader in) { | |||
* prefix</a>, <code>")]}'\n"</code>. | |||
* <li>Streams that include multiple top-level values. With strict parsing, | |||
* each stream must contain exactly one top-level value. | |||
* <li>Top-level values of any type. With strict parsing, the top-level |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This and the changes below in this file are based on #1609 and the comments there.
This specific sentence was outdated because Gson already supports top-level values of other types, even in strict mode.
@@ -321,6 +319,18 @@ public JsonReader(Reader in) { | |||
* {@code :}. | |||
* <li>Name/value pairs separated by {@code ;} instead of {@code ,}. | |||
* </ul> | |||
* | |||
* <p>Note: Even in strict mode there are slight derivations from the JSON |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe this should clarify that these derivations are not guaranteed behavior and might change in the future?
0452999
to
cbd2f84
Compare
Thanks for doing this! I'm merging as-is, but feel free to convert some of the open questions into other PRs or new issues. |
Thanks for merging this!
The main open problem is probably the missing end of document check for the |
Fixes #1720
Resolves #1923
Relates to: #372, #763, #1208, #1609
Improves the documentation regarding lenient mode and trailing data handling. The current Gson behavior is still not ideal, but now at least the documentation (hopefully) matches the actual behavior.