我正在使用Key of Object(或Dictionary / Map)创建一个JSON字符串。
尝试反序列化对象时(使用Chrome js
或Jackson
),密钥被理解为字符串。
Map<String, String> rdto = new HashMap<String, String>();
rdto.put("rule", "display");
//
Map<Map<String, String>, String> m = new HashMap<Map<String, String>, String>();
m.put(rdto, "someValue");
ObjectMapper om = new ObjectMapper();
String jsonStr = om.writeValueAsString(m);
System.out.println(jsonStr);
Map m2 = om.readValue(jsonStr, Map.class);
Iterator i = m2.keySet().iterator();
while (i.hasNext())
{
Object v = i.next();
System.out.println(v.getClass()); // << the key of type String, How come!!
}