拼接Josn 串(list存map)
阿新 • • 發佈:2017-06-12
div set turn json cep buffer sub substr except /**
*
* @param list
* @return _Json(單層);
* @throws Exception
*/
public static String getJson(List<Map<String,String>>list) throws Exception{
String data = "";
if(list != null){
data = "";
for(Map<String,String>map : list){
StringBuffer m = new StringBuffer();
m.append("{");
for(String key : map.keySet()){
m.append("\"" +key + "\":\""+map.get(key)+ "\",");
}
String subString = m.substring(0, m.length() -1)+"}";
data += subString + ",";
}
data = data.substring(0,data.length() - 1);
}else{
data = "";
}
return data;
}
拼接Josn 串(list存map)