0
点赞
收藏
分享

微信扫一扫

OkHttp请求数据回调的时候,response.body.string与toString

boomwu 2021-09-29 阅读 48

当时用OkHttp请求数据,得到json数据但是当时用response.body().toString()将得到的是com.squareup.okhttp.Call$RealResponseBody@41c16aa8;而当你使用string也就是response.body().string()会得到正确的json数据。
在stackoverflow上查到的解释是:

  1. .toString(): This returns your object in string format.(以字符串的格式返回你的对象)
  2. .string(): This returns your response。(返回你的response)
    更加详细的解释就只有看源码了。
    参考:https://stackoverflow.com/questions/28300359/cant-get-okhttps-response-body-tostring-to-return-a-string
举报

相关推荐

0 条评论