问题:
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