You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Our JSON mapper has support for enums as types in our objects, but we only support the constant itself or an upper case version. This means if Facebook uses the enum value test the enum constant may be test or TEST.
This is ok so far, but we are not that flexible in naming our enum constants. To improve this, I suggest using an annotation on the constants and use the provided value in the annotation for the mapping in both directions.
The enum constants can be annotated with our Facebook annotation and can have a different value.
For example @Facebook("test") FOO will convert the incoming String test to the FOO enum, if the enum is used in a type and the other way around. The FOO constant will be converted to the String "test" on converting the object to JSON.
Important: It is not necessary to set the annotation to allow the usage of the constant. The former default behavior is still active.
Our JSON mapper has support for enums as types in our objects, but we only support the constant itself or an upper case version. This means if Facebook uses the enum value
test
the enum constant may betest
orTEST
.This is ok so far, but we are not that flexible in naming our enum constants. To improve this, I suggest using an annotation on the constants and use the provided value in the annotation for the mapping in both directions.
GSON uses some similar approach:
To access this value, there is this method:
The text was updated successfully, but these errors were encountered: