Value of type java.lang.String cannot be converted to JSONArray

后端 未结 4 1104
情深已故
情深已故 2020-12-02 02:55

I\'ve spent 2 days to find a solution with of problem.

Here is the error:

E/log_tag: Error parsing data org.json.JSONException: Value of type java.l         


        
4条回答
  •  悲&欢浪女
    2020-12-02 03:40

    Your Json response seems just fine. However its not always guaranteed that the response string is always filled up with data. For that, I would suggest you to handle your array as below:

    JSONArray jsonArr = null;
    
    String jsonObjRecv = JSONGet.getJSONfromURL(URL_LIST);
    if(!TextUtils.isEmpty(jsonObjRecv)){
        jsonArr = new JSONArray(jsonObjRecv);
    }
    else{
        Log.w("json", "jsonObjRecv is null");
    }
    

提交回复
热议问题