Every CFAJAX example I've seen thus far has only shown the transmission of simple datatypes from Javascript to a CFAJAX handler Coldfusion file. I wanted to go a step further and bring a completely native Javascript JSON object into Coldfusion.
Make sure you have the newest implementations of the following:
json.js version '2007-01-10' or later from http://www.json.org/js.html (Greatness from Douglas Crockford)
JSON.cfc version 1.7 or later from http://www.epiphantastic.com/cfjson/ (Greatness from Jehiah Czebotar)
The goal is to send the Javascript object in the serialized JSON string to the Coldfusion CFAJAX handler - after a little massaging. I immediately found that the single quote ' and pound/number # symbols - if embedded in strings in the object - will throw Coldfusion errors.
To simply attack this problem, simply use the Javascript escape() function or encodeURI() on the JSON serialized string prior to sending through the _execute function. This essentially "URL encodes" the JSON-serialized string making it safe for Coldfusion to receive. For example:
On the receiving end - we must simply URLDecode the incoming string with a little extra massaging and then it is safe to use the Json.cfc's decode()
function. We must parse out the # symbol which is ever-sensitive in the world of coldfusion. I found it better to completely strip this character from the incoming string prior to JSON-deserialization. For example: