FasterXML / jackson-dataformat-xml

Extension for Jackson JSON processor that adds support for serializing POJOs as XML (and deserializing from XML) as an alternative to JSON
Apache License 2.0
561 stars 221 forks source link

`JacksonXmlAnnotationIntrospector.findNamespace()` should properly merge namespace information #637

Closed cowtowncoder closed 5 months ago

cowtowncoder commented 5 months ago

(note: offshoot of #628)

Looks like method findNamepace() in JacksonXmlAnnotationIntrospector is considering both @JsonProperty and @JacksonXmlNamespace (latter having precedence) but does not support case like so:

       @JsonProperty(value="value", namespace="uri:ns1")
        @JacksonXmlProperty(isAttribute=true)
        public int valueDefault = 42;

in which @JacksonXmlProperty does not define namespace (that is, is left as "", empty String). In such case it should then return namespace value of @JsonProperty instead.

Ideally in future we could simply use methods from AnnotationIntrospection -- findNameForSerialization() and findNameForDeserializaiton -- which also expose "namespace", but on short term let's handle merging better.