开发者

JSON Parsing impossible, but JSON Lint says it's ok

I am using jquery to receive a few lines of javascript and get this err

Unexpected token ILLEGA

This is the complete json I am trying to parse. JSON Lint does not complain...

{
    "executionResult": "",
     "outputText": "",
     "stacktraceText": "groovy.lang.MissingPropertyException: No such property: asfdsf for class: Script1\n at Script1.run(Script1.groovy:1)\n  at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)\n  at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)\n  at org.sitemesh.webapp.contentfilter.ContentBufferingFilter.bufferAndPostProcess(ContentBufferingFilter.java:169)\n at org.sitemesh.webapp.contentfilter.ContentBufferingFilter.doFilter(ContentBufferingFilter.java:126)\n at org.sitemesh.config.ConfigurableSiteMeshFilter.doFilter(ConfigurableSiteMeshFilter.java:163)\n   at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)\n  at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)\n  at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:366)\n   at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:109)\n at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:83)\n    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:378)\n   at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:97)\n    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:378)\n   at org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:100)\n    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:378)\n   at org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:78)\n  at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:378)\n   at org.springframework.security.web.authentication.rememberme.RememberMeAuthenticationFilter.doFilter(RememberMeAuthenticationFilter.java:119)\n    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:378)\n   at org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:54)\n  at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:378)\n   at org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:35)\n    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:378)\n   at org.springframework.security.web.authentication.www.BasicAuthenticationFilter.doFilter(BasicAuthenticationFilter.java:177)\n at org.springframework.security.开发者_运维知识库web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:378)\n   at org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter.doFilter(AbstractAuthenticationProcessingFilter.java:187)\n   at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:378)\n   at org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:105)\n    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:378)\n   at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:79)\n   at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:378)\n   at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:167)\n  at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:237)\n    at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:167)\n  at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)\n  at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)\n  at de.hybris.platform.util.RootRequestFilter.doFilter(RootRequestFilter.java:883)\n at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)\n  at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)\n  at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)\n    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)\n    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)\n  at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)\n  at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)\n  at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:554)\n  at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)\n    at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:859)\n at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588)\n   at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:396)\n"
}


Your JSON is fine, so apparently what you're asking jQuery to parse isn't quite what you've quoted, as jQuery is happy to parse it. In that example I'm loading the JSON text via ajax.

If you're reading the JSON text from a JavaScript string rather than by loading it from somewhere, e.g.:

var str = '{ ' +
          '"executionResult": "",' +
          '"outputText": "",' +
          '"stacktraceText": "..."' +
          '}';

...then quote the actual string literal you're trying to parse, and we can tell you what's wrong with it. But that JSON is fine.


The string value inside the quotes assigned to stacktraceText is the problem. JK's comment hit the nail on the head.

You are clearly trying to deal with an error message (exception) received somewhere that is not intended to be parsed in the way you are doing it.

If you have control of the error message make it make sense in the context of a value pair which is normally expected for JSON.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜