-
-
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
Prevent coercion of int
from empty String to null
if DeserializationFeature .FAIL_ON_NULL_FOR_PRIMITIVES
is true
#1095
Comments
So you would not want empty String to be coerced into 'missing' value of '0'? Perhaps a |
I tried to add ObjectMapper mapper = new ObjectMapper();
mapper.enable(DeserializationFeature.ACCEPT_EMPTY_STRING_AS_NULL_OBJECT);
mapper.enable(DeserializationFeature.FAIL_ON_NULL_FOR_PRIMITIVES);
int i = mapper.readValue("\"\"", int.class);
System.out.println(i); The right order in my mind is empty Json String -> Json Null -> Json Number -> primitive. |
@yzmyyff Correct, the features in question are handled separately. Or, I should say, coercion from empty String into scalars does NOT consider |
I think this would make sense. I elaborated bit more on #1106. |
Thanks a lot. |
int
from empty String to null
if DeserializationFeature .FAIL_ON_NULL_FOR_PRIMITIVES
is true
Implemented for 2.7.1; affects primitives, but not equivalent wrappers, as per naming of features. |
What should I do if i want this
to throw Exception? |
Was about to say that it works, but then realized you are talking about wrapper object.
|
@cowtowncoder |
@gkozyryatskyy Ok I'll have a look; since this issue is closed, I'll file a new one. |
@cowtowncoder |
Ok actually I misspoke here. Due to backwards compatibility requirements, So: #1106 will actually be needed here; feature to be added is |
I got 0 from the code below.
It seems that Json Number type cannot start with ".
Could I make the code throw some Exceptions?
The text was updated successfully, but these errors were encountered: