Map<String, Object> map 集合转 json数组, json数组转list ,按条输出到es
遍历 map
for (Entry<String, Object> entry : map.entrySet()) {
System.out.println("Key = " + entry.getKey() + ", Value = " + entry.getValue()); String pathFile = "E:/2/" + "KeyKey.txt"; String jsonEntry= new Gson().toJson(entry.getValue()) + ""; FileUtils.append(pathFile , jsonEntry); // JSONArray jsonarray = JSONArray.fromObject(jsonEntry); String str = ""; System.out.println("--jsonEntry---" +jsonEntry.length()); if (jsonEntry.length() >19) { List<Object> list = JSONObject.parseArray(jsonEntry,Object.class); for (int i = 0; i < list.size(); i++) { System.out.println(list.get(i)); FileUtils.append("E:/2/" + entry.getKey() +"_json.txt", list.get(i)+""); } FileUtils.append("E:/2/" + "19KeyKey.txt", entry.getValue()+""); }else { FileUtils.append("E:/2/" + "11KeyKey.txt", entry.getValue()+""); } }