I'm creating json from JAXB annotated classes. While this works fine for 
most classes in the code base, I've been having some trouble with 
XmlElementWrapper. I've enabled the feature 
USE_WRAPPER_NAME_AS_PROPERTY_NAME, yet I keep getting an error about 
multiple fields having the same name.

The following is a minimal class to reproduce the problem:
@XmlAccessorType(XmlAccessType.FIELD)
public class MyClass {
    @XmlElement(name="value")
    private String currentValue;

    @XmlElementWrapper(name="previousValues")
    @XmlElement(name="value")
    private String[] previousValues;

}

The issue was encountered using version 2.5.4 (and reproduced with 2.8.6). 
After some investigation I found the cause to be in 
POJOPropertiesCollector._renameWithWrappers(). The method looks like it 
expects to do a one-one renaming, so having two fields with the same 
XmlElement name causes it fall over before it actually reads the name on 
the XmlElementWrapper. To me this is odd because you know you may change 
some names, so duplicates shouldn't matter until renaming is complete. The 
XmlElement annotation on the array should not affect anything because I've 
enabled the USE_WRAPPER_NAME_AS_PROPERTY_NAME feature.

I understand that xml and json have different approaches to this, so my 
main question is if this is a bug or intentional?

Thanks in advance.

-- 
You received this message because you are subscribed to the Google Groups 
"jackson-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to