I use Gson in a slightly “different” way, and I wonder if the following is possible ...
I would like to change the default serialization / deserialization format for enums so that it uses fully qualified class names, but supports @SerializedName annotation support in the specified enums. Basically, given the following listing ...
package com.example;
public class MyClass {
public enum MyEnum {
OPTION_ONE,
OPTION_TWO,
@SerializedName("someSpecialName")
OPTION_THREE
}
}
I would like the following to be true ...
gson.toJson(MyEnum.OPTION_ONE) == "com.example.MyClass.MyEnum.OPTION_ONE"
&&
gson.toJson(MyEnum.OPTION_TWO) == "com.example.MyClass.MyEnum.OPTION_TWO"
&&
gson.toJson(MyEnum.OPTION_THREE) == "someSpecialName"
and vice versa.
( , , , switch if-elses + , , , Intent.ACTION_VIEW .. ).
- , , , @SerializedName ? TypeAdapter?
.