I am using modified version 2.1.0 to deserialize JSON in pojos. A field in pojo can be obtained under different names in json. To deserialize the field correctly, I used the @serializedName annotation as follows:
@AutoValue public abstract class Media implements Parcelable { @SerializedName(value = "title", alternate = {"name"}) public abstract String title();
However, for some reason, when there is a field under the key "header" as a result of JSON, Gson reads it correctly, but when the field is associated with a "name", it is not read.
How can I get GSON to recognize an alternate name during deserialization?
source share