Skip to content

@JsonAppend not following sort order specified in @JsonPropertyOrder #1827

@markwoon

Description

@markwoon

@JsonAppend javadoc claims to respect @JsonPropertyOrder but I'm not seeing that in version 2.9.2:

Simple test case:

  @Test
  public void testAppendOrder() throws Exception {

    AppendOrder data = new AppendOrder();
    ObjectMapper om = new ObjectMapper();
    String json = om.writer().withAttribute("@id", "1").writeValueAsString(data);
    System.out.println(json);
    assertTrue(json.indexOf("foo") > json.indexOf("@id"));
  }

  @JsonAppend(attrs = {
      @JsonAppend.Attr(value="@id", include= JsonInclude.Include.NON_EMPTY),
  })
  @JsonPropertyOrder(value = {"@id", "foo"})
  private static class AppendOrder {
    public String foo = "foo";
  }

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