Skip to content

@JacksonXmlProperty appears to behave differently than @JsonProperty when used on java records #665

Open
@alexkolson

Description

@alexkolson

Hello there,

First off, I have created a test repository on github where you can see this for yourself, either in the github action runs or by checking it out locally and running mvn test: jackson-annotation-processing-experiment.

It seems that as soon as one specifies a @JacksonXmlProperty annotation on a java record property, then one has to supply the localName argument to the annotation, otherwise, when deserializing an xml document into the record representation, you get a "Duplicate creator property" error. This is different behavior than @JsonProperty, which one can specify on a record without supplying it any arguments and it works just fine.

I am aware that one can simply not add any annotation, and deserialization works just fine. I noticed this issue though when trying to use isAttribute=true on a @JacksonXmlProperty on a java record, as an xml document I need to deserialize uses attributes. I am also aware that once you specify localName, deserialization also works. What puzzles me is that the simple presence of a @JacksonXmlProperty annotation on a java record seems to require the specification of localName, whereas this does not appear to be the case for @JsonProperty.

Any help or tips or ideas you have would be greatly appreciated!

And of course thanks for making such an awesome tool for us, and I realize you owe me absolutely nothing but if you do happen to get a moment to look at this, it would be super cool!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions