Using Gson to parse Json array and object with no name

前端 未结 4 1112
执念已碎
执念已碎 2021-02-15 23:02

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:35

    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

提交回复
热议问题