Deserializing Map<Object, Object> with GSon
问题 I have a Map containing a mixture of types like in this simple example 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<LinkedHashMap<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()