org.json.JSONException: Value [email protected] of type java.lang.String cannot be converted to JSONObject

okhttp请求数据然后由json解析数据,在日志warn中发现:


出现这个错误的原因是因为json解析出错。
首先我确认我解析的代码无错误,找到源头才发现是返回的json数据有问题。

ResponseBody data=response.body();
String json=data.toString();
processData(json);

上面的data.toString应该改为data.string()。
原因:

data.toString返回的是json对象,data.string()返回的才是json数据。

上图:
data.toString返回数据

data.string()返回数据

原文地址:https://www.cnblogs.com/dearnotes/p/12230891.html

时间: 2024-08-30 15:25:28

org.json.JSONException: Value [email protected] of type java.lang.String cannot be converted to JSONObject的相关文章

org.json.JSONException: Value of type java.lang.String cannot be converted to JSONObject

Value of type java.lang.String cannot be converted to JSONObject 解析服务器返回的Json串时,JSONObject对象抛出了这个异常. 原以为是返回的json格式错误了,仔细对比看不出所以然.至少字符上看是格式没问题的.. 那就可能是编码的问题了.仔细比较每个字符,的确在json串头部发现字符:"\ufeff" . 客户端解决方案: 1 public static final String removeBOM(Strin

spring mvc出现 Failed to convert property value of type 'java.lang.String' to required type 'java.util.Date' for property 'endtime'

在使用spring mvc中,绑定页面传递时间字符串数据给Date类型是出错: Failed to convert property value of type [java.lang.String] to required type [java.util.Date] for property 'expert.birthdate'; nested exception is java.lang.IllegalArgumentException: Cannot convert value of typ

Name for argument type [java.lang.String] not avai

项目通过MyEclipe部署到Tomcat运行一切OK 使用Jekins,Ant进行管理,部署也OK,但是访问项目时就出现: Name for argument type [java.lang.String] not available, and parameter name information not found in class file either. 参考 http://m.blog.csdn.net/blog/kouwoo/42869779 采用第二种方法最活力,使用Ant编译ja

javax.el.PropertyNotFoundException: Property 'name' not found on type java.lang.String

javax.el.PropertyNotFoundException: Property 'name' not found on type java.lang.String javax.el.BeanELResolver$BeanProperties.get(BeanELResolver.java:193) javax.el.BeanELResolver.property(BeanELResolver.java:267) javax.el.BeanELResolver.getValue(Bean

Struts 2.x 与Spring4.x整合出现:No mapping found for dependency [type=java.lang.String, name='actionPackages...

Struts2.16与Spring4.x整合出错: Caused by: java.lang.RuntimeException: com.opensymphony.xwork2.inject.DependencyException: com.opensymphony.xwork2.inject.ContainerImpl$MissingDependencyException: No mapping found for dependency [type=java.lang.String, name

页面不能访问,抛出 spring java.lang.IllegalArgumentException: Name for argument type [java.lang.String] 异常

情况描述: web工程在windows环境eclipse下编译部署没有问题,使用ant打包部署到jboss上,启动正常没有错误,访问一些页面也没有问题,但是有的页面确不能访问,抛出异常如下: 13:28:17,656 ERROR [[springmvc]] Servlet.service() for servlet springmvc threw exceptionjava.lang.IllegalArgumentException: Name for argument type [java.l

Property 'id' not found on type java.lang.String问题解决

一般出现上述问题:存在两种情况 1.你的程序的属性没有提供getter方法 2.在<c:forEach var="list" items="${requestScope.list}" varStatus="vs">这里你没有采取EL表达式 但是我却犯了一个很弱智的错误 在这里items="${requestScope.list}"我写成了 items=" ${requestScope.list}"

Property &#39;XXX&#39; not found on type java.lang.String解决方案

一,标签指令错误. 原指令标签: [java] view plain copy <%@ taglib prefix="c" uri="http://j ava.sun.com/jstl/core" %> 改正后的指令标签: [java] view plain copy <%@ taglib prefix="c" uri="http://j ava.sun.com/jsp/jstl/core" %> 二,

spring3+struts2+hibernate3整合出现的问题,No mapping found for dependency [type=java.lang.String, name=&#39;struts.objectFactory.spring.enableAopSupport&#39;]

七月 11, 2016 3:49:24 下午 org.apache.tomcat.util.digester.SetPropertiesRule begin警告: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.jee.server:EBook' did not find a matching property.七月 11, 2016 3:4