public static JSONObject propsFilter(Object obj, String... props) {
JSONObject jsonObject = new JSONObject();
newArrayList(props).forEach(prop -> {
try {
String[] namePair = prop.split(":");
jsonObject.put(namePair.length > 1 ? namePair[1] : namePair[0], getProperty(obj, namePair[0]));
} catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException e) {
e.printStackTrace();
}
});
return jsonObject;
}
json过滤器
最新推荐文章于 2023-04-02 13:04:02 发布