I'm trying to deserialize the following json:
{ "books": [ {"id":"1","name":"book 1"}, {"id":"2","name":"book 2"} ] }
Into a List. It worked before with this json:
[ {"id":"1","name":"book 1"}, {"id":"2","name":"book 2"} ] }
Using this code:
List<Book> items = new JSONDeserializer<ArrayList<Book>>()
.use("values", Book.class).deserialize(json, ArrayList.class);
But now after looking at multiple examples I am at a loss, is it possible to deserialize directly into a list?
Taking the sample from @vikke I successfully applied the deserialization of a list of longs.
under flexjson 1.9.2 below
List list = new JSONDeserializer>().use(null, ArrayList.class).use("values", Long.class).deserialize( episodeIds ); System.out.println( list );
Okay I think I found an acceptable solution, although I do not know how optimal it is
Will result in a list of books. If anyone maybe have a more "proper" solution feel free to comment.
try this. Its working with me.