拼接Josn 串(list存map)

/**
  * 
  * @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;
 }

  

posted @ 2017-06-12 19:43  令狐る侠  阅读(241)  评论(0编辑  收藏  举报