← Back to blog
·1 min read
How to parse a list of Objects using Google GSON
java
I ran today into a problem, I tried to parse a list of objects coming from a JSON string with a single method avoiding iteration and conversion of individual items of the array. So… after reviewing the doc I found I was able to do something like this.
Gson parser = new Gson();
Type listType = new TypeToken<List<Person>>(){}.getType();
List<Person> persons = parser.fromJson(jsonString, listType);
Follow me at @rasensio