Java - 通过JSONObject 实现字段权限过滤
public static void main(String[] args) {
Map<String, Object> map = new HashMap<>();
map.put("name", "hy");
map.put("password", "123456");
Map<String, String> map2 = new HashMap<>();
map2.put("name", "hy");
map2.put("password", "123456");
map.put("map", map2);
PropertyPreFilters.MySimplePropertyPreFilter excludefilter = new PropertyPreFilters().addFilter();
excludefilter.addExcludes(new String[]{"password"});
System.out.println(JSONObject.toJSONString(map, excludefilter));
}
print:
{"name":"hy","map":{"name":"hy"}}