Skip to content

Instantly share code, notes, and snippets.

@Richie97
Created April 12, 2013 17:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Richie97/5373818 to your computer and use it in GitHub Desktop.
Save Richie97/5373818 to your computer and use it in GitHub Desktop.
Gson Array parsing test
String json = "[{\"id\":5,\"name\":\"Action\"},{\"id\":6,\"name\":\"Adventure\"}]";
@Test
public void testJsonArray() throws Exception {
parseJson();
}
void parseJson(){
Type t = new TypeToken<List<Result>>(){}.getType();
List<Result> result = new Gson().fromJson(json, t);
Assert.assertEquals(2, result.size());
}
private static class Result{
int id;
String name;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment