Map转换成Json:
1 /** 2 * 将Map转换为JSON格式数据 3 * 从Map中抽取数据返回JSON格式数据 4 * @param map Map<String, String[]> 5 * @return 6 * @see [类、类#方法、类#成员] 7 */ 8 9 public JSONObject mapToJson(Map<String, String[]> map) 10 { 11 if (null == map) 12 { 13 return null; 14 } 15 Set<Map.Entry<String, String[]>> set = map.entrySet(); 16 JSONObject jObject = new JSONObject(); 17 18 for (Iterator<Map.Entry<String, String[]>> it = set.iterator(); it.hasNext();) 19 { 20 Map.Entry<String, String[]> entry = it.next(); 21 jObject.put(entry.getKey(), entry.getValue()[0]); 22 } 23 return jObject; 24 }