jackson-databind icon indicating copy to clipboard operation
jackson-databind copied to clipboard

`JsonFormat.Shape.POJO` (or `Shape.OBJECT`) does not work for `Map.Entry` via property annotation

Open cowtowncoder opened this issue 9 years ago • 3 comments

(note: follow-up of #865)

Although use of class annotations works for Map.Entry serialization and deserialization, per-property annotation doesn't. The reason for this is that it significantly easier to block default (de)serialization from being used when class has the annotation; for per-property annotation this has to be done from within createContextual().

cowtowncoder avatar Oct 17 '16 05:10 cowtowncoder

Quick addition: same is true for java.util.Map as well.

I am starting to think that perhaps at least shape should be a required part for interaction through SerializerFactory, DeserializerFactory; and if so, should it be passed as parcel of some kind (JsonFormat.Value would, for example, contain it)

cowtowncoder avatar Nov 19 '16 00:11 cowtowncoder

I'm trying to understand the impact of this issue: does that mean that certain Maps (e.g. with complex types as keys) annotated with @JsonSerialize(using=[some serializer]) and @JsonDeserialize(using=[some deserializer]) simply don't work and you're not providing helpful feedback and let this fall through to com.fasterxml.jackson.databind.exc.InvalidDefinitionException: Cannot find a (Map) Key deserializer for type [simple type, class richtercloud.project1.jar.entities.offer.OfferProperty] or similar?

krichter722 avatar Mar 11 '18 12:03 krichter722

@krichter722 No, this issue is specifically about use of @JsonFormat(shape = ....) either through Class annotation or property (declaration of a property for given type).

Question of use of @JsonSerialize and @JsonDeserialize is somewhat orthogonal, although of course there can be overlap with some combination of annotations.

Plus handling of Map Key values is yet another subject with its own complications (see keyUsing property).

cowtowncoder avatar Mar 11 '18 18:03 cowtowncoder