MismatchedInputException: Cannot deserialize instance of `com.fasterxml.jackson.databind.node.ObjectNode` out of VALUE_NULL token
See original GitHub issueWhen using readerForUpdating and updating an existing objectNode to a null Node this exception is triggered
com.fasterxml.jackson.databind.exc.MismatchedInputException: Cannot deserialize instance of `com.fasterxml.jackson.databind.node.ObjectNode` out of VALUE_NULL token
at [Source: UNKNOWN; line: -1, column: -1]
at com.fasterxml.jackson.databind.exc.MismatchedInputException.from(MismatchedInputException.java:59)
at com.fasterxml.jackson.databind.DeserializationContext.reportInputMismatch(DeserializationContext.java:1468)
at com.fasterxml.jackson.databind.DeserializationContext.handleUnexpectedToken(DeserializationContext.java:1242)
at com.fasterxml.jackson.databind.DeserializationContext.handleUnexpectedToken(DeserializationContext.java:1148)
at com.fasterxml.jackson.databind.deser.std.JsonNodeDeserializer$ObjectDeserializer.deserialize(JsonNodeDeserializer.java:107)
at com.fasterxml.jackson.databind.deser.std.JsonNodeDeserializer$ObjectDeserializer.deserialize(JsonNodeDeserializer.java:82)
at com.fasterxml.jackson.databind.deser.std.BaseNodeDeserializer.updateObject(JsonNodeDeserializer.java:361)
at com.fasterxml.jackson.databind.deser.std.BaseNodeDeserializer.updateObject(JsonNodeDeserializer.java:373)
at com.fasterxml.jackson.databind.deser.std.JsonNodeDeserializer$ObjectDeserializer.deserialize(JsonNodeDeserializer.java:120)
at com.fasterxml.jackson.databind.deser.std.JsonNodeDeserializer$ObjectDeserializer.deserialize(JsonNodeDeserializer.java:82)
at com.fasterxml.jackson.databind.ObjectReader._bindAndClose(ObjectReader.java:2081)
at com.fasterxml.jackson.databind.ObjectReader.readValue(ObjectReader.java:1696)
at com.fasterxml.jackson.databind.ObjectReader.readValue(ObjectReader.java:1711)
Version information Jackson : 2.11.4 Java : openjdk-15.0.2
To Reproduce
@Test
void test() throws IOException {
ObjectMapper objectMapper = new ObjectMapper();
ObjectNode node = objectMapper.createObjectNode();
node.set("test", objectMapper.createObjectNode());
ObjectNode update = objectMapper.createObjectNode();
update.set("test", NullNode.getInstance());
ObjectReader objectReader = objectMapper.readerForUpdating(node);
ObjectNode afterUpdateNode = objectReader.readValue(update, ObjectNode.class);
}
Expected behavior
In the code above node
starts as
{
"test": {}
}
and updated with the object update
containing
{
"test": null
}
after the update is applied afterUpdateNode
should contain the following
{
"test": null
}
But instead the above exception is raised. This looks to be same as #2325 but that was closed by the originator
Issue Analytics
- State:
- Created 3 years ago
- Comments:7 (4 by maintainers)
Top Results From Across the Web
Cannot deserialize instance of `java.util.ArrayList` out of ...
I have developed code but getting below error. com.fasterxml.jackson.databind.exc.MismatchedInputException: Cannot deserialize instance of `java ...
Read more >Cannot deserialize value of type java.util.ArrayList<com ...
Hi Guys, I am POSTing to https://api.infusionsoft.com/crm/rest/v2/contacts Example: { "email_addresses": { "0": { "email": "email@gmail.com" ...
Read more >cannot deserialize instance out of start_array token - You.com
Im trying to deserialize a JSON list into a custom class with a list-typed parameter. However, this fails with com.fasterxml.jackson.databind.exc.
Read more >Jackson Exceptions - Problems and Solutions - Baeldung
This exception is thrown if Jackson can't create an instance of the class, which happens if the class is abstract or it is...
Read more >[Solved] com.fasterxml.jackson.databind.exc ...
[Solved] com.fasterxml.jackson.databind.exc. MismatchedInputException: Cannot deserialize instance of `XYZ` out of START_ARRAY token · Example of ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop 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
Top GitHub Comments
Sorry please ignore that I’ve just seen the comments in the file I added.
Doh!.
Unfortunately I have been unable to make it so that IDE auto-import would auto-generate that file: running
mvn compile
will create it.