Skip to content

Allow using @JsonPropertyOrder with "any" (@JsonAnyGetter) properties #4388

Description

@cowtowncoder

Describe your Issue

Currently @JsonPropertyOrder can only be used with regular (or "true") properties, and it will have no effect on:

  1. "any properties" specified with @JsonAnyGetter
  2. "unwrapped properties" that result from @JsonUnwrapped

It would be good to improve so that at least groups could be ordered, so that f.ex following:

@JsonPropertyOrder({ "id", "unwrapped", "name", "any" })
public class POJO {
   public int id;
   public String name;

   @JsonAnyGetter
   protected Map<String, Object> any;

   @JsonUnwrapped
   protected Values unwrapped;
}

would sort output properties as expected, so unwrapped properties of Values unwrapped would be after id but before name, and "any properties" from Map<> any would be serialized after everything else.
No ordering would be imposed based within "any" or "unwrapped" properties (although @JsonPropertyOrder(alphabetic = true) could be taken into account as well; this would be #518.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    2.19Issues planned at 2.19 or later

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions