org.json.JSONException: End of input at character

前端 未结 9 1127
南旧
南旧 2020-12-03 18:42

when I try to get json that doesn\'t have object, it works fine. but when I try go get json that has an object it\'s getting error.

Have you got any idea?

         


        
相关标签:
9条回答
  • 2020-12-03 19:22

    as you can see from this answer, you are probably getting a blank response.
    in general, the org.json.JSONException: End of input at character N of... means that the JSON couldn't be parsed and something is not being done right.

    if the problem is that you're getting a blank response, you should make sure you get a response from the server before trying to parse it (like ρяσѕρєя K's answer).

    if the problem is a bad JSON, you should try and validate it. JSONLint is a very good place to start.

    0 讨论(0)
  • 2020-12-03 19:24
    JSONArray array=    new JSONArray(resultdata);
                for(int i=0;i<array.length();i++)
                 {                  
                    carid.add(jsonObject.getString("Id"));
                    carlogo.add(jsonObject.getString("CarImage"));
                    carname.add(jsonObject.getString("CarType"));
                    prize.add(jsonObject.getString("Price"));
                    availibility.add(jsonObject.getString("CarAvailable"));}
    
    0 讨论(0)
  • 2020-12-03 19:25

    -please check your all json veriables are properly return only json format or not.

    • Don’t use "http://localhost" or "http://127.0.0.1". Use "http://10.0.2.2" instead.
    0 讨论(0)
提交回复
热议问题