"Input mismatch reading Enum" after upgrade to Jackson 2.11
See original GitHub issueAfter upgrading Jackson from 2.10.3 to 2.11.0 we started to see “Input mismatch reading Enum” errors when deserializing this Koltin Enum class which has a custom @JsonCreator.
To reproduce, you may want to check out this PR and run the added test via
./gradlew :clearly-defined:test --tests org.ossreviewtoolkit.clearlydefined.ClearlyDefinedServiceTest
with and without the Revert "Gradle: Upgrade Jackson to version 2.11.0" commit.
The full error is:
com.fasterxml.jackson.databind.exc.MismatchedInputException: Input mismatch reading Enum `org.ossreviewtoolkit.clearlydefined.ClearlyDefinedService$Provider`: properties-based `@JsonCreator` ([method org.ossreviewtoolkit.clearlydefined.ClearlyDefinedService$Provider#fromString(1 params)]) expects JSON Object (JsonToken.START_OBJECT), got JsonToken.VALUE_STRING
at [Source: (okhttp3.ResponseBody$BomAwareReader); line: 1, column: 87] (through reference chain: org.ossreviewtoolkit.clearlydefined.ClearlyDefinedService$Curation["described"]->org.ossreviewtoolkit.clearlydefined.ClearlyDefinedService$Described["sourceLocation"]->org.ossreviewtoolkit.clearlydefined.ClearlyDefinedService$SourceLocation["provider"])
Issue Analytics
- State:
- Created 3 years ago
- Reactions:6
- Comments:13 (5 by maintainers)
Top Results From Across the Web
Failed to convert boolean to enum using Jackson
I have following java class in a Springboot application
Read more >How to correctly serialize/deserialize an enum with custom ...
I'm going to experiment with a custom deserializer and will post an issue in jackson-databind as you requested. Thanks, David.
Read more >Jackson 2.11.0无法使用@JsonCreator反序列化枚举值
HttpMessageNotReadableException: JSON parse error: Input mismatch reading Enum `xyz.jieee.demo.DemoEnum`: properties-based `@JsonCreator` ...
Read more >DeserializationFeature (jackson-databind 2.11.0 API)
Feature that determines whether JSON integer numbers are valid values to be used for deserializing Java enum values. FAIL_ON_READING_DUP_TREE_KEY.
Read more >Jacksonでenumをシリアライズ - Qiita
DEFAULTで使用すると"Input mismatch reading enum"というエラーメッセージを受け取ってしまいます。内部の型推測のルールが変更されたことが原因のよう ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I’ve encountered this problem with Java too, when using
@JsonCreatoron factory method of an enum with a String parameter. Switching to@JsonCreator(mode = JsonCreator.Mode.DELEGATING)fixed the issue.How’s that:
This works as is with Jackson 2.10.x but fails with aforementioned error on Jackson 2.11 unless
JsonCreator.Mode.DELEGATINGis used or@JsonPropertyis dropped fromfromString()Which Jackson version behaves properly?