Deserializing JSON list into list of objects with Flexjson

我的梦境 提交于 2019-12-06 07:37:34

Taking the sample from @vikke I successfully applied the deserialization of a list of longs.

List<Long> idsLong = new JSONDeserializer<List<Long>>().use("values", Long.class).deserialize("[123,456,789]");

Okay I think I found an acceptable solution, although I do not know how optimal it is

List<Book> items = new JSONDeserializer<Map<String,List<Book>>>().
use("values.values", Book.class).deserialize(json, Map.class).get("books");

Will result in a list of books. If anyone maybe have a more "proper" solution feel free to comment.

under flexjson 1.9.2 below

List list = new JSONDeserializer>().use(null, ArrayList.class).use("values", Long.class).deserialize( episodeIds ); System.out.println( list );

try this. Its working with me.

JavaScriptSerializer jss = new JavaScriptSerializer();

List<Book> lstBook = jss.Deserialize<List<Book>>("your string");
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!