0

Let's assume I have the following pojo

class pojo{
  String color;
}

I want to deserialize color like so:

{
 COLOR: "red"
}

and serialize color like so:

{
 color: "red"
}
Ether
  • 53,118
  • 13
  • 86
  • 159
Fernando
  • 381
  • 1
  • 5
  • 20
  • So your schema says "COLOR", but you want your pojo field to be named color? – Clijsters Dec 07 '20 at 08:52
  • No. The response from somewhere comes as COLOR and want to create my response with color. I don't want to create one pojo for deserializing and one for serializing. It's time consuming. I just want to use one pojo for both tasks. – Fernando Dec 07 '20 at 16:23

1 Answers1

1

If you want to change the name of the property when serializing, you can use the @JsonProperty annotation like this : @JsonProperty("color1")

LE: Now i've understood what you want. You can use @JsonFormat(with = JsonFormat.Feature.ACCEPT_CASE_INSENSITIVE_PROPERTIES) to accept uppercase attributes.

Vladimir Stanciu
  • 1,468
  • 1
  • 7
  • 24