-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Argument type mismatch for enum
with @JsonCreator
that takes String, gets JSON Number
#3006
Comments
I think I would need a smaller reproduction for the issue, without use of Lombok (just include post-processed sources that Lombok would produce). I suspect issue is not related to containment in arrays, but I am bit confused as to why
is used with Enum type. Does leaving that out make any difference? |
I have cut the code from my project. I removed the lombok and wrote a constructor and getter. Got the similar error.
|
Ok, one more thing: instead of iterating over various inputs, could you just include input that fails? So I can see (without yet running) which one of cases fails. But I think the problem is that code expects to support both JSON numbers and JSON Strings as input to Enum creator methods. That would be possible to support with POJOs, by having two separate methods, but
which expects a String, not number; so passing in JSON number does not match. With POJOs you can cover both cases by accepting
in which case you get either Ideally you could just have two creator methods, keeping in mind that |
More than one of
Both cases work with this method. I mean "[1,3]"(numbers) and "["1","3"]"(strings). in 2.11.0. The main question is what influenced this behavior in 2.11.0. (why the numbers stopped working).
|
Yes, 2.10.x may have accidentally behaved in a way you describe, by basically treating all scalar values as if they were text (and accessing numbers using
Another possible improvement might be to allow coercion of number into |
enum
with @JsonCreator
Ok, yes; the problem is that the factory method expects I am bit torn here since on one hand it'd be possible to add specific check for |
enum
with @JsonCreator
enum
with @JsonCreator
that takes String, gets JSON Number
Is there a workaround for this issue until we get the fix? |
Describe the bug
Array of number does not parse.
problem: argument type mismatch (through reference chain: java.lang.Object[][0])
Version information
2.12.0
To Reproduce
Sample in Java
Expected behavior
On version 2.10.5.1 I have two works cases for my sample "[1,3]" and "["1","3"]"
Since 2.11.0 case with JSON "[1,3]" does not work;
I did not find in the change logs changes of this behavior.
The text was updated successfully, but these errors were encountered: