Android JSon error “Expected BEGIN_OBJECT but was BEGIN_ARRAY at line 1 column 2”

前端 未结 3 843
一向
一向 2020-12-01 22:26

I am getting JSon data from a web service, the sample data is given below:

[
  {
    \"SectionId\": 1,
    \"SectionName\": \"Android\"
  }
]
3条回答
  •  庸人自扰
    2020-12-01 23:01

    Use Section class only as follows:

    Section[] sectionArray = new Gson().fromJson(jsonDataFromWebService, Section[].class);
    for (Section section: sectionArray) {
         Log.e("Debug", section.toString());
    }
    

提交回复
热议问题