Parsing JSON Array within JSON Object

后端 未结 5 1641
梦毁少年i
梦毁少年i 2020-11-27 14:45

I have some JSON with the following structure:

{\"source\":[
           {\"name\":\"john\",\"age\":20},
           {\"name\":\"michael\",\"age\":25},
                


        
5条回答
  •  Happy的楠姐
    2020-11-27 15:21

    mainJSON.getJSONArray("source") returns a JSONArray, hence you can remove the new JSONArray.

    The JSONArray contructor with an object parameter expects it to be a Collection or Array (not JSONArray)

    Try this:

    JSONArray jsonMainArr = mainJSON.getJSONArray("source"); 
    

提交回复
热议问题