Share Coding

Tutorials, Problems, Stuffs …

Tag Archives: gson

GSON with reserved word in the data

When using GSON, a object class should be passed to the Gson parser.
How about if there is a field named ‘default’ or other JAVA reserved word in the data?

public class LockerImageSet {

    private String default;

    private String mapImage, buildingImage, lockerImage, aroundImage;

}

The following code shows how to do that by an annotation.

public class LockerImageSet {

    @SerializedName("default")
    private String defaultImage;

    private String mapImage, buildingImage, lockerImage, aroundImage;

}