So I currently use the Jackson parser and its libraries in my android projects. However, looking at the method counts for jackson and gson has me pondering about making a move to gson. After looking through different methods/syntax etc. I have been unable to find a gson equivalent to Jackson's @JsonAnySetter or @JsonAnyGetter.
Does this exist for gson? And if not, is there an work around?
No, it doesn't. Gson basically has 2 commonly used annotations, @Expose
and @SerializedName
. To do what @JsonAnySetter
and @JsonAnyGetter
do, you'd have to write and register your own TypeAdapter
that will group all fields that don't have a acorresponding Field
and add them to a Map
.
Jackson has so many more methods because it is a more complete API, with a larger feature set.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With