jQuery MiniUI

标题: JSON转换报错 [打印本页]

作者: wu95311    时间: 2015-5-7 08:39:51     标题: JSON转换报错

[{"sid":1,"sentryid":1,"sqty":"13","sprice":13,"samount":1,"_id":1,"_uid":1,"_state":"modified"},{"sid":1,"sentryid":2,"sqty":"23","sprice":124,"samount":1,"_id":2,"_uid":2,"_state":"modified"}]
flexjson.JSONException: Failed to parse sqty with yyyy-MM-dd'T'HH:mm:ss pattern.
        at flexjson.transformer.DateTransformer.instantiate(DateTransformer.java:33)
        at flexjson.ObjectBinder.bind(ObjectBinder.java:90)
        at flexjson.ObjectBinder.bindIntoMap(ObjectBinder.java:118)
        at flexjson.factories.MapObjectFactory.instantiate(MapObjectFactory.java:19)
        at flexjson.ObjectBinder.bind(ObjectBinder.java:90)
        at flexjson.ObjectBinder.bindIntoCollection(ObjectBinder.java:105)
        at flexjson.factories.ListObjectFactory.instantiate(ListObjectFactory.java:13)
        at flexjson.ObjectBinder.bind(ObjectBinder.java:90)

        at flexjson.ObjectBinder.bind(ObjectBinder.java:69)
        at flexjson.JSONDeserializer.deserialize(JSONDeserializer.java:150)
        at com.tengzhi.ckgl.controller.JSON.Decode(JSON.java:29)
        at com.tengzhi.ckgl.controller.TzrkController.saveBillData(TzrkController.java:135)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)

        at org.springframework.web.method.support.InvocableHandlerMethod.invoke(InvocableHandlerMethod.java:219)
        at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:132)
        at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:104)
        at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandleMethod(RequestMappingHandlerAdapter.java:745)

        at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:686)
        at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:80)
        at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:925)
        at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:856)
        at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:936)

        at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:838)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:646)
        at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:812)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
        at org.springframework.orm.hibernate4.support.OpenSessionInViewFilter.doFilterInternal(OpenSessionInViewFilter.java:152)

        at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
        at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88)
        at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)

        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220)
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122)
        at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:501)
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:170)
        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:98)

        at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:950)
        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)
        at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1040)
        at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:607)
        at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.doRun(AprEndpoint.java:2441)

        at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.run(AprEndpoint.java:2430)
        at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918)
        at java.lang.Thread.run(Thread.java:662)
Caused by: java.text.ParseException: Unparseable date: "sqty"
        at java.text.DateFormat.parse(DateFormat.java:337)
        at flexjson.transformer.DateTransformer.instantiate(DateTransformer.java:31)
        ... 53 more



作者: felt    时间: 2015-5-7 09:44:34

你的数据格式是怎样,哪个环节转换出问题
作者: wu95311    时间: 2015-5-7 15:58:27

felt 发表于 2015-5-7 09:44
你的数据格式是怎样,哪个环节转换出问题

[{"sid":1,"sentryid":1,"sqty":"13","sprice":13,"samount":1,"_id":1,"_uid":1,"_state":"modified"},{"sid":1,"sentryid":2,"sqty":"23","sprice":124,"samount":1,"_id":2,"_uid":2,"_state":"modified"}]
这是数据格式,在服务端转换出错
作者: felt    时间: 2015-5-7 16:57:37

wu95311 发表于 2015-5-7 15:58
[{"sid":1,"sentryid":1,"sqty":"13","sprice":13,"samount":1,"_id":1,"_uid":1,"_state":"modified"},{ ...

请提供你转换的java代码
作者: wu95311    时间: 2015-5-8 17:53:06

felt 发表于 2015-5-7 16:57
请提供你转换的java代码

JSON.Decode(jsondata);
作者: felt    时间: 2015-5-10 12:56:18

wu95311 发表于 2015-5-8 17:53
JSON.Decode(jsondata);

请参考我们试用开发包中的后台json方法,都是可以正常使用




欢迎光临 jQuery MiniUI (http://miniui.com/discuss/) Powered by Discuz! X2