org.json.JSONException: End of input at character 0 of
错误
解析json数据, 控制台报错
org.json.JSONException: End of input at character 0 of
详细错误
2022-09-20 17:34:47.109 7596-8022/com.example.electronicmall W/System.err: org.json.JSONException: End of input at character 0 of
2022-09-20 17:34:47.109 7596-8022/com.example.electronicmall W/System.err: at org.json.JSONTokener.syntaxError(JSONTokener.java:460)
2022-09-20 17:34:47.109 7596-8022/com.example.electronicmall W/System.err: at org.json.JSONTokener.nextValue(JSONTokener.java:101)
2022-09-20 17:34:47.109 7596-8022/com.example.electronicmall W/System.err: at org.json.JSONObject.<init>(JSONObject.java:164)
2022-09-20 17:34:47.109 7596-8022/com.example.electronicmall W/System.err: at org.json.JSONObject.<init>(JSONObject.java:181)
2022-09-20 17:34:47.109 7596-8022/com.example.electronicmall W/System.err: at com.example.electronicmall.test.User.UserDetailRecordsActivity$1$1.onResponse(UserDetailRecordsActivity.java:137)
2022-09-20 17:34:47.109 7596-8022/com.example.electronicmall W/System.err: at com.squareup.okhttp.Call$AsyncCall.execute(Call.java:168)
2022-09-20 17:34:47.109 7596-8022/com.example.electronicmall W/System.err: at com.squareup.okhttp.internal.NamedRunnable.run(NamedRunnable.java:33)
2022-09-20 17:34:47.109 7596-8022/com.example.electronicmall W/System.err: at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
2022-09-20 17:34:47.109 7596-8022/com.example.electronicmall W/System.err: at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
2022-09-20 17:34:47.109 7596-8022/com.example.electronicmall W/System.err: at java.lang.Thread.run(Thread.java:929)
解决方法
对于返回数据, 若无法确定是否为空, 需要进行判断, 若非空且json数据合法, 再进行json数据解析。
原因
org.json.JSONException: End of input at character 0 of
表明返回值为空, 数据无法被正常解析, 故会报此错误。
原创不易
转载请标明出处
如果对你有所帮助 别忘啦点赞支持哈
还没有评论,来说两句吧...