Created
April 12, 2013 17:49
-
-
Save Richie97/5373818 to your computer and use it in GitHub Desktop.
Gson Array parsing test
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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