首页 > 代码库 > 拼接Josn 串(list存map)

拼接Josn 串(list存map)

/**
  * 
  * @param list
  * @return _Json(单层);
  * @throws Exception
  */
 public static String getJson(List<Map<String,String>>list) throws Exception{
  String datahttp://www.mamicode.com/= "";
  if(list != null){
   datahttp://www.mamicode.com/= "";
   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 = http://www.mamicode.com/data.substring(0,data.length() - 1);
  }else{
   datahttp://www.mamicode.com/= "";
  }
  return data;
 }

拼接Josn 串(list存map)