On Mon, Mar 5, 2018 at 6:14 PM,  <m...@vslice.co.uk> wrote:
> For bean setters we have
> https://github.com/FasterXML/jackson-databind/issues/1402, which AFAICT
> allows to specify different behaviour for nulls vs missing keys.
>
> I want to achieve the same but also preserve immutability (and sanity).
> What's the simplest way of doing that? Sniffing around the code base I see
> `PropertyValueBuffer._findMissing` just uses the deserializer's null value,
> and I don't understand Jackson's extension points well.
>
> In my case I'm using Java 8/9 Optionals and the observed behaviour is as
> follows:
>
> - Field has a value: I get Optional.of(value)
> - Field is null: I get Optional.empty()
> - Field key is missing: I get Optional.empty()
>
> How do I distinguish between case 2 and 3?

You can not distinguish them. You can get an exception, if you want,
by marking specific property/-ies
passed as required (@JsonProperty(required=true)), but that's it.

-+ Tatu +-

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

Reply via email to