I have a class serialized by GSON into JSON. One particular field should be deserialized but not serialized, i.e., read from JSON but not written to JSON.
I know how to completely exclude properties by marking them as transient, and I know about the @Expose
annotation, and, in essence what I need is @Expose(serialize = false)
, but currently I don't have the excludeFieldsWithoutExposeAnnotation
setting set, and I'd prefer not to because I think it really clutters my classes (I do want to serialize all other fields expect this only one in one single class).
Is there any way I could achieve deserialization but not serialization of one particular field without having to resort to explicitly annotating everything else with @Expose
? If I need to resort to a custom serializer of this one class, what is the smoothest way of accomplishing the default behaviour short of this one field that should be ignored when serializing?