Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

@JsonPropertyOrder not respected with defined attributes #91

Closed
thrykol opened this issue Jan 16, 2014 · 3 comments
Closed

@JsonPropertyOrder not respected with defined attributes #91

thrykol opened this issue Jan 16, 2014 · 3 comments
Milestone

Comments

@thrykol
Copy link

thrykol commented Jan 16, 2014

I've noticed that attributes in a POJO must be included first in the @JsonPropertyOrder annotation list in order for the other properties to be ordered.

It is my understanding that the properties in the ordered list take precedence while unlisted properties will follow the ordered properties in any order.

I am using version 2.3.1 from maven central.

In the test class

public class OrderTest
{
    private String a = "first";
    @JacksonXmlProperty(isAttribute = true)
    private String b = "attribute";
    private String c = "second";

    public static void main(String[] args)
        throws Exception
    {
        XmlMapper xmlMapper = new XmlMapper();
        xmlMapper.configure(SerializationFeature.INDENT_OUTPUT, true);
        xmlMapper.writeValue(System.out, new OrderTest());
    }

    public String getA()
    {
        return a;
    }

    public String getB()
    {
        return b;
    }

    public String getC()
    {
        return c;
    }
}

annotating the class with either @JsonPropertyOrder({"a", "c"}) or @JsonPropertyOrder({"a", "c", "b"}) results in orderless output while the annotation @JsonPropertyOrder({"b","a", "c"}) orders properly.

@cowtowncoder
Copy link
Member

Interesting. It does sound like a bug; partial ordering should be fine.

cowtowncoder added a commit that referenced this issue Jan 28, 2014
@cowtowncoder
Copy link
Member

Yes, I can reproduce the issue, and added a unit test.

@cowtowncoder
Copy link
Member

Simple bug, fixed for 2.3.2. Thank you for reporting this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants