json-iterator / java

jsoniter (json-iterator) is fast and flexible JSON parser available in Java and Go
http://jsoniter.com/
MIT License
1.51k stars 518 forks source link

windows系统 tomcat9解析jsonarray报错 #194

Closed 853103174 closed 6 years ago

853103174 commented 6 years ago

项目所有的环境都是utf-8 eclipse+tomcat9开发环境没有问题,项目打成war包放到tomcat9里面报错 有1条数据的时候 [{"number":null,"referencePrice":null,"purchaseDate":"2018-06-17","marketPlan":null,"purchaseQuantity":50,"goods":"芒果","id":1}] 就不报错 多条数据就报错 关键是为什么截断了json串
代码: String data=request.getParameter("data"); List datas = JsonIterator.deserialize(data).asList();

错误 com.jsoniter.spi.JsonException: readStringSlowPath: invalid unicode character, head: 115, peek: ,"goods":", buf: [{"number":null,"referencePrice":null,"purchaseDate":"2018-06-17","marketPlan":null,"purchaseQuantity":50,"goods":"芒果","id":1},{"number":null,"referencePrice":null,"purchaseDate":"2018-06-17","marketPlan":null,"purchaseQuantity":60,"goods":"黄瓜","id":2},{"number":null,"referencePrice":null,"purchaseDate":"2018-06-17","marketPlan":null,"purchaseQuantity":120,"goods":"黄油桃","id":3}] at com.jsoniter.JsonIterator.reportError(JsonIterator.java:136) at com.jsoniter.IterImpl.readStringSlowPath(IterImpl.java:288) at com.jsoniter.IterImplString.parse(IterImplString.java:94) at com.jsoniter.IterImplString.readString(IterImplString.java:64) at com.jsoniter.JsonIterator.readString(JsonIterator.java:206) at com.jsoniter.any.StringLazyAny.fillCache(StringLazyAny.java:128) at com.jsoniter.any.StringLazyAny.toString(StringLazyAny.java:120) at pss.produce.controller.ProduceController.sendWeChat(ProduceController.java:106) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at com.jfinal.aop.Invocation.invoke(Invocation.java:73) at com.jfinal.core.ActionHandler.handle(ActionHandler.java:78) at pss.login.LoginHandler.handle(LoginHandler.java:27) at com.jfinal.ext.handler.FakeStaticHandler.handle(FakeStaticHandler.java:58) at com.jfinal.core.JFinalFilter.doFilter(JFinalFilter.java:73) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:199) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96) at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:494) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:139) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92) at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:651) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343) at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:412) at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66) at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:754) at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1385) at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) at java.lang.Thread.run(Thread.java:748)

853103174 commented 6 years ago

server.xml Connector port="8080" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443" URIEncoding="utf-8"

taowen commented 6 years ago
    public void test2() {
        String data = "[{\"number\":null,\"referencePrice\":null,\"purchaseDate\":\"2018-06-17\",\"marketPlan\":null,\"purchaseQuantity\":50,\"goods\":\"芒果\",\"id\":1},{\"number\":null,\"referencePrice\":null,\"purchaseDate\":\"2018-06-17\",\"marketPlan\":null,\"purchaseQuantity\":60,\"goods\":\"黄瓜\",\"id\":2},{\"number\":null,\"referencePrice\":null,\"purchaseDate\":\"2018-06-17\",\"marketPlan\":null,\"purchaseQuantity\":120,\"goods\":\"黄油桃\",\"id\":3}]";
        List datas = JsonIterator.deserialize(data).asList();
        System.out.println(datas);
    }

can not reproduce the bug

853103174 commented 6 years ago

附件为我用的tomcat 在webapps文件夹里面有源码 数据库, 访问地址是 http://127.0.0.1:8080/pss/produce/purchasePlanList.html 点击发布按钮 就你看见错误了 注意要用 startup.bat 方式启动

在2018年07月03 11时48分, "Tao Wen"notifications@github.com写道:

Closed #194.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or mute the thread.

从网易163邮箱发来的超大附件 apache-tomcat-9.0.8.rar (24.8M, yyyy年M月d日 HH:mm 到期) 下载