jackson-dataformat-xml
jackson-dataformat-xml copied to clipboard
Make JsonTypeInfo As.WRAPPER_ARRAY work
Currently only some of As.xxx modes work (AS_PROPERTY); rest should also made to work.
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.
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.