public static void main(String[] args) throws IOException { String dataStr =""; File file = new File("/Users/zhangpengfei/Desktop/zpf/email.json"); List<String> datas = FileUtils.readLines(file); File file1 = new File("/Users/zhangpengfei/Desktop/zpf/result.json"); int ids = 2549; for (String email : datas) { email = email.toLowerCase(); JSONObject jsonObject = JSON.parseObject(dataStr); ids++; String id = "2021" + ids; long time = System.currentTimeMillis(); JSONPath.set(jsonObject, "$.Attr.Values[C == 'create_time'].V", time); JSONPath.set(jsonObject, "$.Attr.Values[C == 'update_time'].V", time); JSONPath.set(jsonObject, "$.Attr.Values[C == 'email'].V", email); JSONPath.set(jsonObject, "$.Attr.Values[C == 'id'].V", id); JSONPath.set(jsonObject, "$.PK.Values[0]", email); FileUtils.writeLines(file1, Arrays.asList(JSON.toJSONString(jsonObject)), true); System.out.println(JSON.toJSONString(jsonObject)); } // for (String email : datas) { // JSONObject jsonObject = JSON.parseObject(dataStr); // Object create = JSONPath.eval(jsonObject, "$.Attr.Values[C == 'create_time']"); // Object userName = JSONPath.eval(jsonObject, "$.Attr.Values[C == 'userName'].V[0]"); // if (!ObjectUtils.isEmpty(create)) { // // origStr = origStr.replace("username",trimUserName(String.valueOf(userName))); // origStr = origStr.replace("data",String.valueOf(create)); // FileUtils.writeLines(file1, Arrays.asList(origStr),true); // System.out.println(origStr); // } // } System.out.println(); // JSONArray array = JSONArray.parseArray(data); }
02-20
585
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
06-07
“相关推荐”对你有帮助么?
-
非常没帮助
-
没帮助
-
一般
-
有帮助
-
非常有帮助
提交