Larry Garfield
07/24/2024, 3:16 PMKlitos Kyriacou
07/24/2024, 3:19 PMLarry Garfield
07/24/2024, 3:20 PMLarry Garfield
07/24/2024, 3:22 PMenum class AvailabilityReasonCode(val string: String) {
Match("match"),
Character("character"),
Error("error"),
// ...
}
ashmelev
07/24/2024, 3:28 PM@Enumerated(EnumType.ORDINAL)
or
@Enumerated(EnumType.STRING)
It defaults to ORDINAL as I recallLarry Garfield
07/24/2024, 3:29 PMLarry Garfield
07/24/2024, 3:30 PMRiccardo Lippolis
07/24/2024, 3:31 PMtrue
, otherwise you could also annotate the string
property with @JsonValue
ashmelev
07/24/2024, 3:31 PMMatch
or Error
. Though I typically use all caps for enum values.Larry Garfield
07/24/2024, 3:33 PMenum class AvailabilityReasonCode(
@JsonValue
val string: String
) {
Match("match"),
Character("character"),
Error("error"),
// ...
}
?ashmelev
07/24/2024, 3:34 PMmatch
ashmelev
07/24/2024, 3:34 PMMatch
ashmelev
07/24/2024, 3:35 PM0
Riccardo Lippolis
07/24/2024, 3:35 PM@get:JsonValue
instead), but I would try your version firstLarry Garfield
07/24/2024, 3:37 PMmatch
in it, while using Availability::Match
in code.Larry Garfield
07/24/2024, 3:41 PMashmelev
07/24/2024, 3:42 PMstring
value yourselfRiccardo Lippolis
07/24/2024, 3:43 PM@get:JsonValue
as well?Larry Garfield
07/24/2024, 3:44 PMLarry Garfield
07/24/2024, 3:44 PMRiccardo Lippolis
07/24/2024, 3:47 PMKlitos Kyriacou
07/24/2024, 3:48 PM@get:JsonValue
to work. Try using JsonProperty:
enum class AvailabilityReasonCode {
@JsonProperty("match") Match,
@JsonProperty("character") Character,
@JsonProperty("error") Error,
// ...
}
(Also, as Riccardo says, use a recent version of Jackson)Larry Garfield
07/24/2024, 3:51 PMLarry Garfield
07/24/2024, 3:53 PMKlitos Kyriacou
07/24/2024, 3:59 PMLarry Garfield
07/24/2024, 4:00 PMLarry Garfield
07/24/2024, 4:00 PMLarry Garfield
07/24/2024, 4:01 PMLarry Garfield
07/24/2024, 5:10 PM