Rename JSON fields used by MappingJacksonJsonView in Spring

后端 未结 2 655
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-01-01 18:53

I\'m using MappingJacksonJsonView to serialize to JSON a class, however, I\'d like to be able to rename some of the fields from the default name based on the getter name.

2条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-01-01 19:04

    Have you tried using the @JsonProperty annotation?

    "Defines name of the logical property, i.e. Json object field name to use for the property: if empty String (which is the default), will use name of the field that is annotated."

提交回复
热议问题