serialize and deserialize enum with Gson [duplicate]

You can try this.

import com.google.gson.annotations.SerializedName;

public enum Color {

    @SerializedName("0")
    RED (0), 

    @SerializedName("1")
    BLUE (1),

    @SerializedName("2")
    YELLOW (2);

    private final int value;
    public int getValue() {
        return value;
    }

    private Color(int value) {
        this.value = value;
    }

}

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)