Skip to content

[REQ][java][jackson] add @JsonPropertyOrder annotation #3629

@jmini

Description

@jmini

When the model classes are serialized to JSON the order of the JSON members are not controlled.

Given this schema:

components:
  schemas:
    SomeObj:
      type: object
      properties:
        id:
          type: integer
          format: int64
        firstName:
          type: string
        lastName:
          type: string

This is not a big deal because the order is not relevant in a JSON object:

{
"id" : 42,
"firstName": "John",
"lastName": "Doe"
}

Is the same than:

{
"lastName": "Doe",
"id" : 42,
"firstName": "John"
}

But if the JSON objects are displayed or stored as file, it would be nice to have always the same order (the same as in the OpenAPI specification).

With Jackson the solution is to use the @JsonPropertyOrder property.

In my opinion this should be generated (maybe with an option to hide it for user that do not want it).

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions