FasterXML / jackson-annotations

Core annotations (annotations that only depend on jackson-core) for Jackson data processor
https://github.com/FasterXML/jackson
Apache License 2.0
1.03k stars 330 forks source link

Null value handling with @JsonSerializer #22

Closed cgendreau closed 10 years ago

cgendreau commented 11 years ago

It looks like a custom @JsonSerializer will never be used with null values even if @JsonInclude(Include.ALWAYS) is used. I guess the null handling is at the ObjectMapper level but it would be nice to provide custom null handling at field/getter level. Maybe a @JsonNullSerializer or another parameter on @JsonSerializer?

cowtowncoder commented 11 years ago

This is bit tricky to do, but others have expressed similar desire for more granular null serializer configuration. So it's just question of how to do this efficiently, also considering that code to handle this is scattered over multiple structured serializers (Map, List, array serializers at least, in addition to BeanSerializer).

cowtowncoder commented 11 years ago

Oh. Also, this should be filed at jackson-databind -- annotations project is only about adding annotation property, and in this case that is trivial compared to making things actually work.