jackson-dataformat-xml icon indicating copy to clipboard operation
jackson-dataformat-xml copied to clipboard

Make JsonTypeInfo As.WRAPPER_ARRAY work

Open cowtowncoder opened this issue 14 years ago • 2 comments

Currently only some of As.xxx modes work (AS_PROPERTY); rest should also made to work.

cowtowncoder avatar Jan 03 '11 07:01 cowtowncoder

Hmmh. WRAPPER_OBJECT now works (with classname escaping/quoting)... have to think about how to implement WRAPPER_ARRAY. Perhaps it just should be handled as a synonym for WRAPPER_OBJECT.

cowtowncoder avatar Jan 14 '11 22:01 cowtowncoder

Quick note: indeed, translating WRAPPER_ARRAY -> WRAPPER_OBJECT would probably be the way to go. With 2.9 it is easy to do this for serialization (JsonGenerator.writeTypePrefix() allows this). Alas, same is not true for reading side.

Another approach that would work for both sides would be to try to latch on to TypeResolverBuilder, change it there (there is method inclusion() to change it). But getting to modify this is kind of involved. One way is by overriding method findTypeResolver() in AnnotationIntrospector, but unfortunately XmlMapper does not (have to) register custom AI as of now (2.9.0).

Yet another approach would be to try to replace AsArrayTypeDeserializer or perhaps add logic in std implementation to tackle the case for XML (where we get START_OBJECT, instead of type id).

None of these seems quite satisfactory; and although with some changes to jackson-databind it might be doable we are not in position to change API right after 2.9.0. So... above is just musing, no immediate solution found.

cowtowncoder avatar Aug 03 '17 20:08 cowtowncoder