这是indexloc提供的服务,不要输入任何密码
Skip to content

Possible 2.16.0 Enum-as-JSON-Object serialization regression #4564

@cowtowncoder

Description

@cowtowncoder

Discussed in #4563

Originally posted by Mugiwara84 June 5, 2024
Hi,
I am using jackson with spring to serialize a java enumeration which looks like this :

@JsonFormat(shape = JsonFormat.Shape.OBJECT)
public enum Level {
  LEVEL1("level1"),
  LEVEL2("level2"),
  LEVEL3("level3", Level.LEVEL1);

  String label;
  Level sublevel;

.......
}

Before updating to 2.16.0, I was getting this when serializing :

[
  {
    "label": "level1"
  },
  {
    "label": "level2"
  },
  {
    "label": "level3",
    "sublevel": {
        "label": "level1"
    }
  }
]

Since 2.16.0, I'm getting :

[
  {
    "label": "level1"
  },
  {
    "label": "level2"
  },
  {
    "label": "level3"
  }
]

Is this the expected behaviour ?
Is there a different way to achieve the previous result with parameters or annotations ?

Metadata

Metadata

Assignees

No one assigned

    Labels

    enumRelated to handling of Enum values

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions