問題:
Default jackon behaviour seems to use both properties (getters and setters) and fields to serialize and deserialize to json.默認 jackon 行爲似乎同時使用屬性(getter 和 setter)和字段來序列化和反序列化爲 json。
I would like to use the fields as the canonical source of serialization config and thus don't want jackson to look at properties at all.我想使用這些字段作爲序列化配置的規範來源,因此根本不希望 jackson 查看屬性。
I can do this on an individual class basis with the annotation:我可以使用註釋在單個類的基礎上執行此操作:
@JsonAutoDetect(fieldVisibility = Visibility.ANY, getterVisibility = Visibility.NONE, setterVisibility = Visibility.NONE)
But I don't want to have to put this on every single class...但我不想把它放在每一門課上......
Is it possible to configure this globally?是否可以全局配置? Like add some to the Object Mapper?像添加一些到對象映射器?
解決方案:
參考一: https://en.stackoom.com/question/ToWn參考二: https://stackoom.com/question/ToWn