Jackson ObjectMapper - specify serialization order of object properties

后端 未结 9 1653
梦毁少年i
梦毁少年i 2020-11-27 17:38

I\'m implementing a RESTful web service where user has to send a signed verification token along with the request so that I could ensure that the request has not been tamper

9条回答
  •  时光取名叫无心
    2020-11-27 18:25

    The annotations are useful, but can be a pain to apply everywhere. You can configure your whole ObjectMapper to work this way with

    Current Jackson versions: objectMapper.configure(MapperFeature.SORT_PROPERTIES_ALPHABETICALLY, true)

    Older Jackson versions: objectMapper.configure(SerializationConfig.Feature.SORT_PROPERTIES_ALPHABETICALLY, true);

提交回复
热议问题