I am trying to use Gson to deserialize a json string returned from my webservice
The structure would be returned as TypeDTO[]
.
where TypeDTO
is like
int id;
String name;
ArrayList<ItemDTO> items[]
and ItemDTO is like
int id;
String name;
Boolean valid;
When I call the code as follows
Gson gson = new Gson();
TypeDTO[] mytypes = (TypeDTO[]) gson.fromJson(reply, TypeDTO[].class);
Everything inside the objects is null
However, If I use the
JSONArray
and JSONObject
to pull them out piece by piece from the org.json jars, it works fine and the fields are populated accordingly.
Any ideas as to what I'm doing wrong? is Gson extremely fast? Or am I better to stick with what I've got working already?
Thanks, David