Gson Help With Parse Array - Works Without Array But Won't With Array
Can somebody help me with Gson parser. When I remove change from JSON and Result it works fine but with change it throws JsonParseException-Parse failed. Result[] response = gson.
Solution 1:
As has been suggested, you need to use a list instead. Gson has pretty good documentation for using parametized types with the parser, you can read more about it here. Your code will end up looking like this:
Type listType = new TypeToken<List<Result>>() {}.getType();
List<Result> results = gson.fromJson(reader, listType);
for (Result r : results) {
System.out.println(r);
}
Post a Comment for "Gson Help With Parse Array - Works Without Array But Won't With Array"