Fix missing list elements

This commit is contained in:
Andrea Cavalli 2021-06-30 10:58:13 +02:00
parent 37e8d9ae8a
commit 51eaeaae33
1 changed files with 3 additions and 1 deletions

View File

@ -314,7 +314,9 @@ public abstract class MoshiPolymorphic<OBJ> {
public List<T> fromJson(@NotNull JsonReader jsonReader) throws IOException { public List<T> fromJson(@NotNull JsonReader jsonReader) throws IOException {
jsonReader.beginArray(); jsonReader.beginArray();
var result = new ArrayList<T>(); var result = new ArrayList<T>();
result.add(valueAdapter.fromJson(jsonReader)); while (jsonReader.hasNext()) {
result.add(valueAdapter.fromJson(jsonReader));
}
jsonReader.endArray(); jsonReader.endArray();
return Collections.unmodifiableList(result); return Collections.unmodifiableList(result);
} }