Open pattobrien opened 6 months ago
@JsonCodable
annotation already supports enums, but you have to make one extra step for it to work, which is adding @JsonValue
annotation for each value in the enum.
enum Status {
@JsonValue('active')
active,
@JsonValue('inactive')
inactive,
@JsonValue('pending')
pending,
}
@JsonCodable
annotation already supports enums, but you have to make one extra step for it to work, which is adding@JsonValue
annotation for each value in the enum.enum Status { @JsonValue('active') active, @JsonValue('inactive') inactive, @JsonValue('pending') pending, }
It doesn't work for me. I need this too.
Would also like to use JsonCodable() for enums. It would save a lot of work. In the json_annotation package, for example, there is also a @JsonEnum(). Does anyone know a workaround that I can use for Enums in context with JsonCodable without having to remove JsonCodable?
The following code snippet throws an error for enums.
I realize that EnumDeclarations are generally not yet supported by macros, but since this is basic functionality preventing any future migration, that this would be beneficial to document.
info