开源库

OkHttp请求数据回调的时候,response.body.st

2017-10-30  本文已影响0人  毕丙伟

当时用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
上一篇 下一篇

猜你喜欢

热点阅读