Caused by: java.lang.IllegalStateException: Expected BEGIN_OBJECT but was STRING at line 1 column 3939

在使用Gson解析JSON数据时,报错:Caused by: java.lang.IllegalStateException: Expected BEGIN_OBJECT but was STRING at line 1 column 3939

原因:传入的参数有问题;

while((len=inputStream.read(data))!=-1){
            outPutStream.write(data,0,len);
        }

错写成:

while((len=inputStream.read())!=-1){
            outPutStream.write(data,0,len);
        }

导致:

String jsonString=HttpUtils.getJsonContent(path);
            System.out.println("jsonString-->:"+jsonString.toString());
            Person person=GsonTools.getPerson(jsonString.trim(), Person.class);

上段GsonTools.getPerson中的jsonString参数有问题,从而引起报错

时间: 2024-08-27 05:36:56

Caused by: java.lang.IllegalStateException: Expected BEGIN_OBJECT but was STRING at line 1 column 3939的相关文章

Caused by: java.lang.IllegalStateException: Detected both log4j-over-slf4j.jar AND slf4j-log4j12.jar on the class path, preempting StackOverflowError

SLF4J: Detected both log4j-over-slf4j.jar AND slf4j-log4j12.jar on the class path, preempting StackOverflowError. SLF4J: See also http://www.slf4j.org/codes.html#log4jDelegationLoop for more details.Exception in thread "main" java.lang.Exception

Caused by: java.lang.IllegalStateException: getOutputStream() has already been called for this respo

1.错误描述 Caused by: java.lang.IllegalStateException: getOutputStream() has already been called for this response at org.apache.catalina.connector.Response.getWriter(Response.java:648) at org.apache.catalina.connector.ResponseFacade.getWriter(ResponseFa

java.lang.IllegalStateException: Expected a string but was BEGIN_ARRAY at line 1 column 296

先贴代码 public class ListDataRequest extends JsonRequest<ArrayList<Note>> { public ListDataRequest(int method, String url,Map<String,String> contentBody, Listener<ArrayList<Note>> listener, ErrorListener errorlistener) {  super(

Caused by: java.lang.IllegalStateException: The specified child already has a parent. You

ViewPager 报错:Caused by: java.lang.IllegalStateException: The specified child already has a parent. You must call removeView() on the child's parent first. 一中是removeView这个问题很常见的,具体解决方法就不谈了,另外一种是情况如下: adapter=new ViewPagerAdapter(Views); views>>  view

ssm项目——异常:Caused by: java.lang.IllegalStateException

异常:Caused by: java.lang.IllegalStateException: Cannot convert value of type 'java.lang.String' to required type 'javax.sql.DataSource' for property 'dataSource': no matching editors or conversion strategy found 大意:java.lang.String 与所需要的javax.sql.Data

Caused by: java.lang.IllegalStateException: duplicate key: datasource

java.lang.IllegalStateException: Failed to load property source from location 'classpath:/application.yaml' at org.springframework.boot.context.config.ConfigFileApplicationListener$Loader.load(ConfigFileApplicationListener.java:537) at org.springfram

Caused by: java.lang.IllegalStateException: Ambiguous mapping found

Caused by: java.lang.IllegalStateException: Ambiguous mapping found. Cannot map ‘myCockpitMgrController’ bean method 报错为:Caused by: java.lang.IllegalStateException: Ambiguous mapping found. Cannot map ‘myCockpitMgrController’ bean method 是因为两个请求,请求到同

【异常】Caused by: java.lang.IllegalStateException: Method has too many Body parameters

出现此异常原因是引文使用feign客户端的时候,参数没有用注解修饰 1.1GET方式错误写法 @RequestMapping(value="/test", method=RequestMethod.GET) Model test(final String name, final int age); 启动服务的时候,会报如下异常: Caused by: java.lang.IllegalStateException: Method has too many Body parameters

caused by: java.lang.IllegalStateException: Method has too many Body parameters: 多参数问题

https://blog.csdn.net/liuchuanhong1/article/details/54728681 多参数问题 @RequestMapping(value="/user/name", method=RequestMethod.GET)   User findByUsername(final String userName, final String address); 启动服务的时候,会报如下异常: Caused by: java.lang.IllegalStat