Android-okhttp、json-org.json.JSONException: Value okhttp3.internal.http.RealResponseBody@163e535 of

org.json.JSONException: Value okhttp3.internal.http.RealResponseBody@163e535 of type java.lang.String cannot be converted to JSONArray

在Android开发中使用okhttp3来读取服务器上的json数据,提示

org.json.JSONException: Value okhttp3.internal.http.RealResponseBody@163e535 of type java.lang.String cannot be converted to JSONArray

下面这个.toString()方法会提示使用该方法可能会出现问题,具体什么问题我也不太清楚。
这里提示

Method invocation 'toString' may produce 'java.lang.NullPointerException' less... (Ctrl+F1) 
This inspection analyzes method control and data flow to report possible conditions that are always true or false, expressions whose value is statically proven to be constant, and situations that can lead to nullability contract violations.
Variables, method parameters and return values marked as @Nullable or @NotNull are treated as nullable (or not-null, respectively) and used during the analysis to check nullability contracts, e.g. report NullPointerException (NPE) errors that might be produced.
More complex contracts can be defined using @Contract annotation, for example:
@Contract("_, null -> null") — method returns null if its second argument is null @Contract("_, null -> null; _, !null -> !null") — method returns null if its second argument is null and not-null otherwise @Contract("true -> fail") — a typical assertFalse method which throws an exception if true is passed to it 
The inspection can be configured to use custom @Nullable
@NotNull annotations (by default the ones from annotations.jar will be used)

搜索一番发现这里原来要改成.String()方法,这样在请求的时候就不会出现类型不匹配的问题。

  • 3
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值