String jsonStr = {"UserId":1,"UserName":"张三","Key":12345678910}
Gson gson=new Gson();
Map<String, Object> resultMap = gson.fromJson(jsonStr, new TypeToken<Map<String, Object>>(){}.getType() );
转换后 UserId=1.0,Key=1.2345678910
这个要肿么办,急!!!!!!
在线等
貌似long型数据默认还转换成16进制了
解析前的key:1362312484950
解析后的key=1.36231248495E12
这是可以直接运行的代码,各位大侠copy到机器上运行一下,看看是不是介个情况,给个回复,谢谢!
String jsonStr = "{\"UserId\":1,\"UserName\":\"张三\",\"Key\":12345678910}";
Gson gson = new Gson();
Map<String, Object> resultMap = gson.fromJson(jsonStr, new TypeToken<Map<String, Object>>(){}.getType() );
for (Iterator<String> it = resultMap.keySet().iterator(); it.hasNext();) {
String key = it.next();
System.out.println(key+":"+resultMap.get(key));
}
慕丝7291255