首页 > 编程知识 正文

将list集合转为json,jsonarray转成list

时间:2023-05-05 22:44:45 阅读:27865 作者:2989

直接上传到代码而不乱说:需要转换为list的json代码:

[{'id':104,' mid':16,' up_count':103,' count_date':'2016-08-15 ',' name ' 3: ] {'id':105,' mid':18,' up_count':104,' count_date':'2016-08-15 ',' name ' 3: } ' last _ contribute _ name ' : '【NDS】节奏天堂LOLI与猴子真人的比较版',' last_contribute_【NDS】{'id':106,' MII ' count_date':'2016-08-15 ',' name ' : ' ' last _ contribute _ id ' :39,' last _ contribu ne _ nn ' last _ contribute _ time ' 3360 ' 2360 ' ' up _ count ' :106,' count_date':'2016-08-15 ',' name ' ' contrib ar ' ' last _ contribute _ name ' : '《逆转裁判5》Soundtrack192k ',' last _ contribute _ time ' 3: ' 2013 -。 ' count_date':'2016-08-15 ',' name': '一条黑色',' fans':422,' contr icing ' last _ contribute _ s ' last _ contribute _ time ' : ' 2013-09-0201336010336035 ' count _ date ' : ' 2016-08-15 ',' name ' 333336360 ' ' last_cood ]少女与坦克——OverPanzer ',' last _ contribute _ time ' : ' 2016-06-1305336028336001 ' }对策建议:建设有list 否则,将抛出转换时转换失败的异常

转换的工具代码:

publicstatictlisttfromjson2array (字符串JSON,ClassT clazz ) throws exception (列表=新阵列列表); jsonarrayarray=newjsonparser (.parse ) JSON ).getAsJsonArray ); for (finaljsonelementelem :阵列) list.add (newgson ).from JSON (elem,clazz ) ); }返回列表; }调用代码:

listbumfansuserinfofanslist=JSON utils.from JSON2array (JSON,BumFansUserInfo.class ); 通过此转换完成了json到list的转换

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。