Expected BEGIN_ARRAY but was BEGIN_OBJECT with an array of three elements

后端 未结 1 1666
一向
一向 2021-01-29 01:57

I\'m developing an Android 3.1 and above application.

I\'m using Spring Framework 1.0.0.0RC1 for Android, and Google GSon 2.1.

I\'m getting an error when I\'m tr

1条回答
  •  野趣味
    野趣味 (楼主)
    2021-01-29 02:34

    as your string starts with "{", which means it is an Object(json concept) and it seems that your considering it as an array, which is wrong.

    EDITED:

    {"data":
       {
        "allFormsResult": [
            {
                "FormId": 1,
                "FormName": "Formulario 1"
            },
            {
                "FormId": 2,
                "FormName": "Formulario 2"
            },
            {
                "FormId": 3,
                "FormName": "Formulario 3"
            }
        ]
      }
    }
    

    just append a object "data", and then continue with you parsing. It is a problem of Json when it got first element as an Array "[".

    0 讨论(0)
提交回复
热议问题