Skip to content

Commit

Permalink
Update Troubleshooting.md and Gson default lenient mode documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
Marcono1234 authored and marten-voorberg committed Apr 18, 2023
1 parent 8453738 commit 8593b57
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Troubleshooting.md
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ Notes:

**Solution:** See [`Gson` class documentation](https://www.javadoc.io/doc/com.google.code.gson/gson/latest/com.google.gson/com/google/gson/Gson.html) section "Lenient JSON handling"

Note: Even in non-lenient mode Gson deviates slightly from the JSON specification, see [`JsonReader.setLenient`](https://www.javadoc.io/doc/com.google.code.gson/gson/latest/com.google.gson/com/google/gson/stream/JsonReader.html#setLenient(boolean)) for more details.
Note: Even in non-lenient mode Gson deviates slightly from the JSON specification, see [`JsonReader.setStrictness`](https://www.javadoc.io/doc/com.google.code.gson/gson/latest/com.google.gson/com/google/gson/stream/JsonReader.html#setStrictness(Strictness)) for more details.

## `IllegalStateException`: "Expected ... but was ..."

Expand Down
9 changes: 5 additions & 4 deletions gson/src/main/java/com/google/gson/Gson.java
Original file line number Diff line number Diff line change
Expand Up @@ -106,12 +106,13 @@
* for a more complete set of examples.</p>
*
* <h2>Lenient JSON handling</h2>
* For legacy reasons most of the {@code Gson} methods allow JSON data which does not
* For legacy reasons most of the {@code Gson} methods by default allow JSON data which does not
* comply with the JSON specification, even when the strictness {@link Strictness#DEFAULT}
* is used. To restrict a {@code Gson} instance from parsing JSON that
* does not comply with the JSON specification, {@linkplain Strictness#STRICT strict} mode should be used.
* Alternatively, if you do not want to use {@linkplain Strictness#STRICT strict} mode,
* the following workarounds can be used:
* does not comply with the JSON specification, {@link Strictness#STRICT} mode should be used.
*
* <p>For older Gson versions which don't have the {@link Strictness} mode API the following
* workarounds can be used:
*
* <h3>Serialization</h3>
* <ol>
Expand Down

0 comments on commit 8593b57

Please sign in to comment.