我想排除弹簧休息响应体的特定属性。经过数小时的谷歌搜索后,我发现了这个:http : //www.jroller.com/RickHigh/entry/filtering_json_feeds_from_spring 由于它的日期,我想问一下jackson和或fastxml是否有更新的东西。JsonView 不符合我的要求,因为我需要涵盖这种情况:
如果 A 是我所有属性的集合:一次我需要用 B ⊂ A 暴露 B。另一次用 C ⊂ A 暴露 C。而 B ∩ C != ∅
这将导致复杂的视图声明以及注释每个类,并且在某些情况下可能也不可能。所以我想做的是与此类似的事情:
@RequestMapping("/test1")
@JsonIgnoreProperties( { "property1"})
public TestObject test1(HttpRequest request){
return new TestObject();
}
@RequestMapping("/test2")
@JsonIgnoreProperties( { "property2"})
public TestObject test1(HttpRequest request){
return new TestObject();
}
输出:
{property2:ipsum,property3:dolor}
{property1:lorem,property3:dolor}