org.json.JSONArray cannot be converted to JSONObject

前端 未结 5 1363
滥情空心
滥情空心 2020-12-01 16:22

I am new to JSON and I am getting the follwoing Exception:

org.json.JSONArray cannot be converted to JSONObject in the first line of try se

5条回答
  •  无人及你
    2020-12-01 17:08

    if that really is the json you are receiving you should replace the entire this:

    JSONObject json = new JSONObject(strResponse);
    
    //Get the element that holds the internship ( JSONArray )
    JSONArray name = json.names();
    JSONArray  internships = json.toJSONArray(name);
    

    with

    JSONArray  internships = json.toJSONArray(strResponse);
    

提交回复
热议问题