At the line
reader.beginArray();
I get the error:
expected beginarray but was beginobject.
I tried changing .beginArray()
to .beginObject()
but it doesn't work.
This code is part of a JsonParser
public List<Noticias> leerArrayNoticias(JsonReader reader) throws IOException {
ArrayList<Noticias> noticias = new ArrayList<>();
try {
reader.beginArray();
while (reader.hasNext()) {
noticias.add(leerNoticia(reader));
}
reader.endArray();
}catch(IOException e){
e.printStackTrace();
}catch(Exception e){
e.printStackTrace();
}
return noticias;
}
Here is the Json that im trying to parse
{"noticias":
[
{"idnoticias":"109","titulo":"nueva1","descripcion":"nuevo1"},
{"idnoticias":"110","titulo":"nueva2","descripcion":"nuevo2"}
]
}