gson 转换复杂类型map
我有个比较复杂的Map对象,我发现我每次用Gson转换成Json串的时候,总是得不到我想要的结果。Map对象大概是长这个样子。{"days":["date","date2...
我有个比较复杂的Map对象,我发现我每次用Gson转换成Json串的时候,总是得不到我想要的结果。
Map对象大概是长这个样子。
{
"days":["date","date2","date3","date4","date5","date6"...],
"counts":[{"name": "name1", "data": ["0","1","3","444"...]},{"name": "name2", "data": ["0","1","3","444"...]},{"name": "name3", "data": ["0","1","3","444"...]}...]
}
但是我每次转换成Json的时候就只有days转换成功了,counts怎么都转不出来。
求大神! 展开
Map对象大概是长这个样子。
{
"days":["date","date2","date3","date4","date5","date6"...],
"counts":[{"name": "name1", "data": ["0","1","3","444"...]},{"name": "name2", "data": ["0","1","3","444"...]},{"name": "name3", "data": ["0","1","3","444"...]}...]
}
但是我每次转换成Json的时候就只有days转换成功了,counts怎么都转不出来。
求大神! 展开
2016-12-07
展开全部
先定义好相应 的类,在GSON中注册
再转换
~~~~~
再转换
~~~~~
追问
不定义类不可以吗?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询