-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Closed
Milestone
Description
I've stumbled upon another situation in which I'm not able to get the textual representation of the current token.
I have the following class:
public class Test {
public Boolean value;
public Boolean getValue() { return value; }
public void setValue(Boolean value) { this.value = value; }
}
And the following object mapper:
ObjectMapper objectMapper = new ObjectMapper();
objectMapper.disable(MapperFeature.ALLOW_COERCION_OF_SCALARS);
I'm trying to deserialize something that would result in a MismatchedInputException
: I'm providing a number to something that expects a boolean:
try {
objectMapper.readValue("{ \"value\": 1.0 }", Test.class);
} catch (MismatchedInputException exception) {
JsonParser parser = (JsonParser) exception.getProcessor();
System.out.println(parser.currentToken());
System.out.println(parser.getText());
} catch (Exception exception) {}
This results in:
VALUE_NUMBER_FLOAT
while I would expect parser.getText()
to return "1.0"
.
Related with #2635. However that one was specifically for InputStream
s, where here it happens for both String
s and InputStream
s.
(Jackson 2.11.0)
Metadata
Metadata
Assignees
Labels
No labels