Capture the JSON output and paste it into a JSON validator like this one: http://jsonformatter.curiousconcept.com/
In my experience, CF over escapes some of the text data, particularly single quotes - JSStringFormat puts a backslash before single quotes which is invalid JSON. I create a JSONStringFormat function myself and simply do a replace(jsonStringFormat(someString),"\'|,"'","ALL") and this fixes it. I know there are probably more efficient way, but this works and I would not be surprised if there are other invalid format cases.
BTW, I have already submitted a bug report on this one.
Hope this helps.
Sorry, maybe I wasn't clear. There is NO json output to capture in this instance. My return type in the CFC is a structure. The only thing that should be returning is that structure. However it seems if there is any error something else is being output even though my function output is set to no. And the errors are fully handled, so nothing should be written to HTML at all for this. When it happens though I get no return data at all, simply that parsejson error. I don't even see a way to find out what it is even trying to parse in order to look at that.
Whether you know it or not, JSON is being used. To pass a structure, most commonly the structure is convertted into a JSON, XML, or WDDX format. Based on the error you are seeing, JSON is being used. This is one of the reasons I don't use the built in ajax/cfc functionality that CF provides and instead write my own using jquery and my own JSON data provider logic -- this way I know the in's and out's in fine detail.
Is there a way to see what is being parsed prior to the parsing and the resulting error? I don't see any way to do it personally. So it leads me back to my original problem of why is it even happening in the first place. The structure returns fine as long as there is no real error, but even if I use <cfthrow> inside a <cftry>, it gets the parsejson error. Even though the error is handled through a <cfcatch>. It makes no sense, I could understand if the error wasn't handled then the error debug data output that I have setup could cause the parsejson error, but with a handled error there should be no output at all.
Could you please illustrate with some code?
RE: Is there a way to see what is being parsed prior to the parsing and the resulting error?
Yep, use Firefox and install the Firebug add-on. It's a priceless tool and it's free.
most of the time i'm using securejson param in the cfc function declaration, like:
<cffunction name="someName" output="false" access="remote" securejson="true">
then i usually do the error trapping inside the function, like:
... do something...
<cfreturn "do something failed"><cfabort>