org.json.JSONException: End of input at character 0 of

古城微笑少年丶 2024-04-06 12:16 152阅读 0赞

错误

解析json数据, 控制台报错

  1. org.json.JSONException: End of input at character 0 of

详细错误

  1. 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
  2. 2022-09-20 17:34:47.109 7596-8022/com.example.electronicmall W/System.err: at org.json.JSONTokener.syntaxError(JSONTokener.java:460)
  3. 2022-09-20 17:34:47.109 7596-8022/com.example.electronicmall W/System.err: at org.json.JSONTokener.nextValue(JSONTokener.java:101)
  4. 2022-09-20 17:34:47.109 7596-8022/com.example.electronicmall W/System.err: at org.json.JSONObject.<init>(JSONObject.java:164)
  5. 2022-09-20 17:34:47.109 7596-8022/com.example.electronicmall W/System.err: at org.json.JSONObject.<init>(JSONObject.java:181)
  6. 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)
  7. 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)
  8. 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)
  9. 2022-09-20 17:34:47.109 7596-8022/com.example.electronicmall W/System.err: at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
  10. 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)
  11. 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数据解析。

原因

  1. org.json.JSONException: End of input at character 0 of

表明返回值为空, 数据无法被正常解析, 故会报此错误。

原创不易
转载请标明出处
如果对你有所帮助 别忘啦点赞支持哈
在这里插入图片描述

发表评论

表情:
评论列表 (有 0 条评论,152人围观)

还没有评论,来说两句吧...

相关阅读