@JacksonXmlElementWrapper as a @JsonCreator parameter not working (original) (raw)

Do you have a plan to make @JacksonXmlElementWrapper specifiable as a parameter?

I'm wondering to use Jackson-dataformat-XML to deserialize to a immutable class instance, but @JacksonXmlElementWrapper is not available as a @JsonCreator parameter. We do a similar approach for JSON by specifying @JsonProperty on @JsonCreator.

For example:

{
  "type": "TYPE",
  "labels": [ "foo", "bar" ]
}

<body>
  <type>TYPE</type>
  <labels><label>foo</label><label>bar</label></labels>
</body>

@JacksonXmlRootElement(localName="body")
public class Body {
    @JsonCreator
    public Body(@JsonProperty("type")
                @JacksonXmlProperty("type")
                String type,
                @JsonProperty("labels")
                @JacksonXmlElementWrapper(localName="labels")
                @JacksonXmlProperty(localName="label")
                Collection<String> labels) {
        // ...
    }

    @JsonProperty("type")
    @JacksonXmlProperty("type")
    public String getType() { return this.type; }

    @JsonProperty("labels")
    @JacksonXmlElementWrapper(localName="labels")
    @JacksonXmlProperty("label")
    public ImmutableList<String> getLabels() { return this.labels; }

    private final String type;
    private final ImmutableList<String> labels;
}