like that:
{"result": {
"update": {
"title": "双11抢10亿现金券啦",
"msg": "峰峰说,升级新版之后双十一抢购杠杠的!新版还有不一样的峰峰彩蛋哦",
},
"ts": 1446446129,
}
Map
Map
map1.put("title","双11抢10亿现金券啦");
map1.put("msg","峰峰说,升级新版之后双十一抢购杠杠的!新版还有不一样的峰峰彩蛋哦");
resultMap.put("update",map1);
resultMap.put("ts","1446446129");
can gson do it above directly?
If your type is Map
You'd need to use a Type rather than a Class, obtained from TypeToken,
since you're tryign to deserialize a parameterized type.
Type typeOfT = new TypeToken<Map<String, Map<String,
String>>>(){}.getType();
Map<String, Map<String, String>> map = gson.fromJson(jsonString, typeOfT);
On Tue, 3 Nov 2015 at 17:31 lytasky [email protected] wrote:
like that:
{"result": {
"update": {
"title": "双11抢10亿现金券啦",
"msg": "峰峰说,升级新版之后双十一抢购杠杠的!新版还有不一样的峰峰彩蛋哦",
},
"ts": 1446446129,
}
Map resultMap = new HashMap<>();
Map map1 = new HashMap<>();
map1.put("title","双11抢10亿现金券啦");
map1.put("msg","峰峰说,升级新版之后双十一抢购杠杠的!新版还有不一样的峰峰彩蛋哦");
resultMap.put("update",map1);
resultMap.put("ts","1446446129");can gson do it above directly?
—
Reply to this email directly or view it on GitHub
https://github.com/google/gson/issues/727.
my type is Map
Most helpful comment
my type is Map>>> , map in map, the level is indefinitely ,only the deepest map is Map