Все работало нормально, но теперь кажется, что одно из полей ответа может иметь форму массива или форму одного элемента, так что я получаю com.google.gson.JsonSyntaxException: java.lang.IllegalStateException:
Здесь вы можете увидеть фрагмент двух версий JSON, вызывающий проблемы:
ВЕРСИЯ 1
Код: Выделить всё
{
"Notes": {
"Note": [
{
"key": "disruption-message",
"section": "high",
"priority": "1",
"message": "The battery consumption raised suddenly."
},
{
"key": "disruption-message",
"section": "low",
"priority": "2",
"message": "The power on the converter might be too high."
}
]
}
}
Код: Выделить всё
{
"Notes": {
"Note": {
"key": "medium",
"section": "low",
"priority": "1",
"message": "Life time for the battery will expire soon"
}
}
}
Код: Выделить всё
public class Notes implements Serializable {
@SerializedName("Note")
@Expose
private List note = null;
public List getNote() {
return note;
}
public void setNote(List note) {
this.note = note;
}
}
Код: Выделить всё
com.google.gson.JsonSyntaxException: java.lang.IllegalStateException: Expected BEGIN_ARRAY but was BEGIN_OBJECT
Подробнее здесь: https://stackoverflow.com/questions/438 ... r-an-array
Мобильная версия