【发布时间】:2018-03-21 21:04:31
【问题描述】:
是否可以使用 Jackson 序列化 POJO 属性的白名单子集(白名单仅在运行时才知道)?
到目前为止,我所知道的所有解决方案(视图、@JsonIgnoreProperties 等)都是静态的、编译时解决方案。
此外,我的后端以以下格式返回结果:
{
"outcome": "SUCCESS", // an enum
"message": "Success.", // a message for the developer
"result": {
// Some result that's different for each call
}
}
所以我正在寻找一种只能应用于对象图的某些部分(如result 属性的内容)的解决方案。
【问题讨论】:
-
你可以使用 JSON 过滤器。
标签: java json serialization jackson2