-
-
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
InvalidDefinitionException
when calling mapper.createObjectNode().putPOJO
#3262
Comments
InvalidDefinitionException: Java 8 date/time type
java.time.LocalDateTime not supported by default
when calling mapper.createObjectNode().putPOJO
InvalidDefinitionException: Java 8 date/time type java.time.LocalDateTime...
when calling mapper.createObjectNode().putPOJO
This is intentional: as per #2683, Java 8 date/time types cannot be serialized (as POJOs) since those cannot be read back (deserialized). The solution is to register module |
I think I am adding the module:
It doesn't actually work in 2.11, it just serializes the date without using the module. I looks like calling any accessor methods on ObjectNode ignores any modules loaded in the Object Mapper which used to create it. My use case is in a unit test checking that the ObjectNode is built correctly - in running code it's not an issue as I always do objectMapper.writeValue but in my tests I just want to check the updatedAt key is correct ( |
Looking at this, the actual problem is the
The problem with I'll have to think about this for a bit; behavior is not optimal but I am not sure what could be done to improve it. |
What would be the best way to retrieve a value added using I have a unit test where I want to make sure that the value added at a particular key is the expected value (I can cope with getting back the POJO or the equivalent JSON value).
Would it be possible to add a |
|
If the Temporal is created as POJONode, this exception will be thrown because of the BaseJsonNode::toString()
|
At this point I can reproduce the issue but don't really know if anything may be done -- my suggestion is that when using "POJO" nodes, use The problem then being that of error handling as there seem to be only bad choices:
|
InvalidDefinitionException: Java 8 date/time type java.time.LocalDateTime...
when calling mapper.createObjectNode().putPOJO
InvalidDefinitionException
when calling mapper.createObjectNode().putPOJO
Went with (3), catching serialization issue specifically for |
We've updated to 2.15 and we've been able to use a PojoNode containing a LocalDateTime in our tests without exceptions being thrown :-) |
Hello,
When running the code below I get the exception:
2.11.4 works as expected.
2.13.0-rc2 fails with the same error.
Main.java
build.gradle
I've tried using AdoptOpenJDK (OpenJ9) 11.0.11 and AdoptOpenJDK (Hotspot) 14.0.2 and I get the same result on both.
The text was updated successfully, but these errors were encountered: