Using Gson to parse Json array and object with no name

前端 未结 4 2221
攒了一身酷
攒了一身酷 2021-02-15 23:04

I know there are many JSON with GSON questions but none of them relate to me directly. My JSON is formatted differently.

I have a JSON data I want to parse using GSON wh

4条回答
  •  梦谈多话
    2021-02-15 23:33

    Some times we get JsonArray [ {..} , {..} ] as a response (without 'itemArray' name like yours) In that case you can use following code

    Type fooType = new TypeToken>() {}.getType();
    List array = new Gson().fromJson(response, fooType);
    

    find more about this Official doc - Gson Array-Examples

提交回复
热议问题