今天写程序实践的,还真能互相转换呢,哈哈哈
JSONObject rt = new JSONObject();
List<Map<String, String>> accData = new ArrayList<Map<String,String>>();
Map<String, String> singleAccData = new HashMap<String, String>();
String attachPath = accDir.replace("/adfad/", "") + "/"+saveName + ext;
String attachTitle = realFileNames[i];
rt.put("accData", JSONObject.toJSON(accData));
return rt.toJSONString();
这是返回的rt然后下面是接收:
String accData = "";//附件字段信息
//这方法返回的参数就是上面return的rt
String djoStr = mbFileTransferService.downloadAttachmentFromMoa();
JSONObject djo = JSONObject.parseObject(djoStr);
accData = djo.getString("accData");
List<String> accData1 = Arrays.asList(accData);
for(String o : accData1){
JSONArray ja = (JSONArray) JSONArray.parse(o);//String形式的Map集合压成JSON数组
for(int i=0;i<ja.size();i++){
System.out.println("heshuang1225:"+((JSONObject) ja.get(i)).getString("key"));
}
}
网友评论