日期:2014-05-16 浏览次数:20494 次
?
public class TmpTest { /** * @param args */ public static void main(String[] args) { final Map<String, Object> map = new LinkedHashMap<String, Object>(); map.put("a", 1); map.put("b", "a"); map.put("c", 2); final Gson gson = new Gson(); final String string = gson.toJson(map); final Type type = new TypeToken<Map<String, Object>>() {}.getType(); final Map<Object, Object> map2 = gson.fromJson(string, type); for (final Entry<Object, Object> entry : map2.entrySet()) { System.out.println(entry.getKey() + " : " + entry.getValue()); } } }