I'm wanting to support a `PATCH` method on the server using JAX-RS with 
RESTEasy. I will do all the patching myself manually; I just need to read 
in a JSON document and figure out if a particular property is set to `null` 
or if it's missing. If the property is set to `null`, I will remove the 
value from the database. If the property isn't set to anything, I will 
leave it untouched in the database. That's pretty much the gist of JSON 
Merge Patch <https://tools.ietf.org/html/rfc7396> as I understand it.

So I added jackson-datatype-jdk8 and added a POJO DTO FooBar in Java that 
has:

public Optional<Boolean> flag = null;

Based on https://github.com/FasterXML/jackson-datatype-jdk8/issues/2 , I 
assumed that if the incoming JSON did not indicate a "flag", then in Java 
the "flag" property would be left as null.

But using com.fasterxml.jackson.datatype:jackson-datatype-jdk8:2.9.5, 
unless I misinterpreted something, if I send a JSON document {} to the 
server, Jackson will construct a FooBar object, not with flag == null as I 
would expect, but with flag == Optional.of(false). So there's no way to 
tell if the incoming JSON patch document was {} or if it was {"flag":false}.

How can I tell the difference?

-- 
You received this message because you are subscribed to the Google Groups 
"jackson-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to