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); }