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
The @JsonCreator and @JsonValue annotations must be supported correctly
Actual Behaviour
Now serialization and deserialization of enums always goes by name, without the ability to customize enums in the form of codes or numeric identifiers.
See below for an example. You will get an exception when trying to deserialize:
17:29:09.735 ERROR [main] c.m.b.c.MyEntityConfig [MyEntityConfig.java:59] - Can't read config for variant VAR2
java.lang.IllegalArgumentException: No enum constant com.micronaut.bug.config.data.VariantEnum.2
at java.base/java.lang.Enum.valueOf(Enum.java:273)
at io.micronaut.serde.support.serdes.EnumSerde.deserializeNonNull(EnumSerde.java:42)
at io.micronaut.serde.support.serdes.EnumSerde.deserializeNonNull(EnumSerde.java:36)
at io.micronaut.serde.util.NullableDeserializer.deserialize(NullableDeserializer.java:38)
at io.micronaut.serde.support.deserializers.SpecificObjectDeserializer.deserializeValue(SpecificObjectDeserializer.java:400)
at io.micronaut.serde.support.deserializers.SpecificObjectDeserializer.deserialize(SpecificObjectDeserializer.java:174)
at io.micronaut.serde.jackson.JacksonJsonMapper.readValue0(JacksonJsonMapper.java:131)
at io.micronaut.serde.jackson.JacksonJsonMapper.readValue(JacksonJsonMapper.java:116)
at io.micronaut.serde.jackson.JacksonJsonMapper.readValue(JacksonJsonMapper.java:160)
at io.micronaut.serde.ObjectMapper.readValue(ObjectMapper.java:46)
at com.micronaut.bug.config.MyEntityConfig.myConfigs(MyEntityConfig.java:55)
at com.micronaut.bug.config.$MyEntityConfig$MyConfigs0$Definition.build(Unknown Source)
Steps To Reproduce
I have configuration in several json-files - var1.json, var2.json. My configuration structure:
ConfigData.java:
graemerocher
changed the title
[BUG?] Can't use @JsonCreator and @JsonValue annotations with serde
[BUG?] Can't use @JsonCreator and @JsonValue on enums
Mar 28, 2022
graemerocher
changed the title
[BUG?] Can't use @JsonCreator and @JsonValue on enums
Can't use @JsonCreator and @JsonValue on enums
Mar 28, 2022
Expected Behavior
The
@JsonCreator
and@JsonValue
annotations must be supported correctlyActual Behaviour
Now serialization and deserialization of enums always goes by name, without the ability to customize enums in the form of codes or numeric identifiers.
See below for an example. You will get an exception when trying to deserialize:
Steps To Reproduce
I have configuration in several json-files -
var1.json
,var2.json
. My configuration structure:ConfigData.java:
VariantEnum.java:
var1.json:
Configuration load:
Problem with methods
in my enum. I want to use specified code or identifier for enum, but now I can use only enum.name. With jackson this logic works fine
Environment Information
Example Application
https://github.com/altro3/micronaut3-bug
Version
3.4.0
The text was updated successfully, but these errors were encountered: