Question

I am getting the following error on my browser:

Exceptions

11:05:30.030 - Application Exception - in C:\mypath\myfile.cfm : line 14

        JSON parsing failure: Unexpected end of JSON string

Where Line #14 is where I am deserializing the JSON like the following:

<cfset incomingData = toString(getHttpRequestData().content) />

line #14:

<cfset djs = DeserializeJSON(incomingData)/>

What does the Application Exception means?

The Stacktrace after dumping variable djs is as follows:

 coldfusion.runtime.JSONUtils$JSONParseOverflowException: JSON parsing failure: Unexpected end of JSON string at coldfusion.runtime.JSONUtils$ParserState.currentChar(JSONUtils.java:1835) at coldfusion.runtime.JSONUtils.parseObject(JSONUtils.java:949) at coldfusion.runtime.JSONUtils.parseJSON(JSONUtils.java:922) at coldfusion.runtime.JSONUtils.deserializeJSON(JSONUtils.java:162) at coldfusion.runtime.CFPage.DeserializeJSON(CFPage.java:6723) at cfgetIncoming2ecfm1847112669.runPage(C:\Websites\ebmdevii\Event-Based-Messaging\public\response\email\getIncoming.cfm:14) at coldfusion.runtime.CfJspPage.invoke(CfJspPage.java:231) at coldfusion.tagext.lang.IncludeTag.doStartTag(IncludeTag.java:416) at coldfusion.filter.CfincludeFilter.invoke(CfincludeFilter.java:65) at coldfusion.filter.ApplicationFilter.invoke(ApplicationFilter.java:381) at coldfusion.filter.RequestMonitorFilter.invoke(RequestMonitorFilter.java:48) at coldfusion.filter.MonitoringFilter.invoke(MonitoringFilter.java:40) at coldfusion.filter.PathFilter.invoke(PathFilter.java:94) at coldfusion.filter.ExceptionFilter.invoke(ExceptionFilter.java:70) at coldfusion.filter.BrowserDebugFilter.invoke(BrowserDebugFilter.java:79) at coldfusion.filter.ClientScopePersistenceFilter.invoke(ClientScopePersistenceFilter.java:28) at coldfusion.filter.BrowserFilter.invoke(BrowserFilter.java:38) at coldfusion.filter.NoCacheFilter.invoke(NoCacheFilter.java:46) at coldfusion.filter.GlobalsFilter.invoke(GlobalsFilter.java:38) at coldfusion.filter.DatasourceFilter.invoke(DatasourceFilter.java:22) at coldfusion.filter.CachingFilter.invoke(CachingFilter.java:62) at coldfusion.CfmServlet.service(CfmServlet.java:200) at coldfusion.bootstrap.BootstrapServlet.service(BootstrapServlet.java:89) at jrun.servlet.FilterChain.doFilter(FilterChain.java:86) at coldfusion.monitor.event.MonitoringServletFilter.doFilter(MonitoringServletFilter.java:42) at coldfusion.bootstrap.BootstrapFilter.doFilter(BootstrapFilter.java:46) at jrun.servlet.FilterChain.doFilter(FilterChain.java:94) at jrun.servlet.FilterChain.service(FilterChain.java:101) at jrun.servlet.ServletInvoker.invoke(ServletInvoker.java:106) at jrun.servlet.JRunInvokerChain.invokeNext(JRunInvokerChain.java:42) at jrun.servlet.JRunRequestDispatcher.invoke(JRunRequestDispatcher.java:286) at jrun.servlet.ServletEngineService.dispatch(ServletEngineService.java:543) at jrun.servlet.jrpp.JRunProxyService.invokeRunnable(JRunProxyService.java:203) at jrunx.scheduler.ThreadPool$DownstreamMetrics.invokeRunnable(ThreadPool.java:320) at jrunx.scheduler.ThreadPool$ThreadThrottle.invokeRunnable(ThreadPool.java:428) at jrunx.scheduler.ThreadPool$UpstreamMetrics.invokeRunnable(ThreadPool.java:266) at jrunx.scheduler.WorkerThread.run(WorkerThread.java:66) 

Note: The same file when I run on different Coldfusion 8 Server located at different IP doesn't throw any error.

Was it helpful?

Solution

The error message is very clear: JSON parsing failure: Unexpected end of JSON string

You're trying to parse a string as JSON, and the string isn't JSON.

Put a try/catch around the erroring line, and in the catch dump out the string you're trying to deserialise. You will undoubtedly see that the string isn't JSON. Hence the error saying it can't be parsed as such.

OTHER TIPS

This worked for me:

<cfset requestBody = toString(getHttpRequestData().content)>
<cfset requestBody = REReplaceNoCase(requestBody,"[\s+]"," ","ALL")>
<cfset requestBody = Trim(requestBody)>
<cftry>
<cfset requestBody = DeserializeJSON(requestBody)>
<cfcatch>
<cfdump var="#requestBody#" />
</cfcatch>
</cftry>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top