Json轉Map主要用動了谷歌的Gson,具體地址以下
java
http://code.google.com/p/google-gson/json
例如:ide
public static void main(String[] args) { String jsonData = "{'name':'韓美美','age':21}"; Map<String,String> map = parseData(jsonData); System.out.println(map.get("name")); } /** * * 函數名稱: parseData * 函數描述: 將json字符串轉換爲map * @param data * @return */ private static Map<String, String> parseData(String data){ GsonBuilder gb = new GsonBuilder(); Gson g = gb.create(); Map<String, String> map = g.fromJson(data, new TypeToken<Map<String, String>>() {}.getType()); return map; }