我正在努力学习Gson,而我正在努力解决现场排斥问题。
public class Student {
private Long id;
private String firstName = ""Philip"";
private String middleName = ""J."";
private String initials = ""P.F"";
private String lastName = ""Fry"";
private Country country;
private Country countryOfBirth;
}
public class Country {
private Long id;
private String name;
private Object other;
}
我可以使用GsonBuilder,并添加一个ExclusionStrategy的字段名称像firstName或,country但我似乎无法设法排除像某些领域的属性country.name。
使用该方法public boolean shouldSkipField(FieldAttributes fa),FieldAttributes不包含足够的信息来匹配字段与过滤器country.name。
使用Gson
<interceptor-ref name=""json"">
<param name=""enableSMD"">true</param>
<param name=""excludeProperties"">
login.password,
studentList.*\.sin
</param>
</interceptor-ref>
相似问题