在线上
reader.beginArray();
我得到错误:
expected beginarray but was beginobject.
我尝试更改.beginArray()
为,.beginObject()
但它不起作用。
此代码是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;
}
这是我试图解析的 Json
{"noticias":
[
{"idnoticias":"109","titulo":"nueva1","descripcion":"nuevo1"},
{"idnoticias":"110","titulo":"nueva2","descripcion":"nuevo2"}
]
}