Closed Marcono1234 closed 1 month ago
@eamonnmcmanus regarding https://github.com/google/gson/discussions/2632#discussioncomment-9481105: Is there some general problem with this concept of a nesting limit or should I change something?
@eamonnmcmanus regarding #2632 (reply in thread): Is there some general problem with this concept of a nesting limit or should I change something?
Last time I looked, this triggered a test failure in a Google-internal test. I think what I might do is patch Google's internal copy of the Gson source code to increase the threshold so that test passes. I think the limit of 255 is reasonable for the public version. I'm looking into this now.
Purpose
Add nesting limit for
JsonReader
Description
For now don't expose this as additional GsonBuilder method assuming that the default nesting limit is high enough for most users. Otherwise users can first obtain a JsonReader from
Gson.newJsonReader
and then set a custom nesting limit.The reasons why this pull request makes the nesting limit configurable at all are
JsonReader
can be used directly in a way which does not involve recursion, so for these advanced use cases there might be no limit needed. It appears there are rare cases where users need to handle more deeply nested JSON data; here are examples from other programming languages: https://github.com/valyala/fastjson/issues/65, https://github.com/serde-rs/json/issues/162#issuecomment-713662554Checklist
mvn verify
, but can also be checked on its own usingmvn spotless:check
.\ Style violations can be fixed usingmvn spotless:apply
; this can be done in a separate commit to verify that it did not cause undesired changes.null
@since $next-version$
(
$next-version$
is a special placeholder which is automatically replaced during release)TestCase
)mvn clean verify javadoc:jar
passes without errors