|
@@ -23,7 +23,7 @@ public class split_names extends UDF {
|
|
|
}
|
|
|
try {
|
|
|
String[] jsonArr = jsons.split("&");
|
|
|
- HashSet<String> set = new HashSet();
|
|
|
+ HashSet<String> set = new HashSet<>();
|
|
|
for (String json : jsonArr) {
|
|
|
parse(json, json_path, set);
|
|
|
}
|
|
@@ -34,18 +34,19 @@ public class split_names extends UDF {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- public void parse(String json, String json_path, Set set) {
|
|
|
+ public void parse(String json, String json_path, Set<String> set) {
|
|
|
JSONArray jsonArray = ((JSONArray) JSONPath.eval(JSON.parse(json), json_path));
|
|
|
for (Object s : jsonArray) {
|
|
|
if (s != null && s.toString().length() > 0) {
|
|
|
- set.add(s);
|
|
|
+ set.add(s.toString());
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
public static void main(String[] args) {
|
|
|
- String jsons = "[{\"name\":\"张海林\",\"litigant_id\":\"\"},{\"name\":\"招商银行股份有限公司信用卡中心\",\"litigant_id\":\"cc45eeb0634f73531ba54ad55ba152a6\"}]&[{\"name\":\"上海浦东发展银行静安支行\",\"litigant_id\":\"c2c57fcc6398cfd49393c1a2d3c35a4c\"}]";
|
|
|
- String json_path = "$.litigant_id";
|
|
|
+ //String jsons = "[{\"name\":\"张海林\",\"litigant_id\":\"\"},{\"name\":\"招商银行股份有限公司信用卡中心\",\"litigant_id\":\"cc45eeb0634f73531ba54ad55ba152a6\"}]&[{\"name\":\"上海浦东发展银行静安支行\",\"litigant_id\":\"c2c57fcc6398cfd49393c1a2d3c35a4c\"}]";
|
|
|
+ String jsons = "[{\"name\":\"南京颍州电气设备有限公司\",\"litigant_id\":\"\",\"date\":\"2010-06-22T00:00:00.000+08:00\",\"exec_money\":3.692949}]";
|
|
|
+ String json_path = "$.exec_money";
|
|
|
split_names n = new split_names();
|
|
|
System.out.println(n.evaluate(jsons, json_path));
|
|
|
}
|