gpt4 book ai didi

java - 解析android中的JSON响应 "response of type org.json.JSONObject cannot be converted to JSONArray"

转载 作者:行者123 更新时间:2023-12-02 05:07:18 24 4
gpt4 key购买 nike

我发现有很多问题,但我认为我遗漏了一个我无法找到的细节。

我收到的响应字符串包含在以下错误中:

12-28 10:25:14.402: W/System.err(2133): org.json.JSONException: Value
{"status":"ok","userTier":"developer","total":1722082,"startIndex":1,"pageSize":5,"currentPage":1,"pages":344417,"orderBy":"newest",
"results":[{"webTitle":"AirAsia flight loses contact with air traffic control between Indonesia and Singapore","webPublicationDate":"2014-12-28T09:06:55Z","sectionName":"World news","sectionId":"world","id":"world\/live\/2014\/dec\/28\/airasia-flight-loses-contact-with-air-traffic-control-on-route-from-indonesia-to-singapore","webUrl":"
... at response of type org.json.JSONObject cannot be converted to JSONArray

我的代码是

JSONObject jObject = new JSONObject(result);// result is the sting response presented above
JSONArray jArray = jObject.getJSONArray("response");

最佳答案

response key 是 JSONObject,您需要使用 getJSONObject 代替当前方法。

关于java - 解析android中的JSON响应 "response of type org.json.JSONObject cannot be converted to JSONArray",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27675255/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com