MapString, Object map 集合转 json数组, json数组转list ,按条输出到es
2019獨角獸企業重金招聘Python工程師標準>>>
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()+"");
?? ??? ??? ??? ?}
?? ??? ??? ?}
轉載于:https://my.oschina.net/thomas2/blog/2994456
《新程序員》:云原生和全面數字化實踐50位技術專家共同創作,文字、視頻、音頻交互閱讀總結
以上是生活随笔為你收集整理的MapString, Object map 集合转 json数组, json数组转list ,按条输出到es的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: java生成HMACSHA256的方法
- 下一篇: [BZOJ4448][SCOI2015]