JSONUtil 1.1

Last year I put together JSONUtil as a proof of concept solution to the issue of ColdFusion's implicit type conversion during JSON serialization. There were some issues with the 1.0 release, and I've had a few people submit patches, but because I had considered the project an experiment I didn't really take the time to update the official release.

Well, last week I was working on an AJAX project where I was making XHR requests to ColdSpring remote proxies using ColdFusion's built in JSON return format when I began running into issues with implicit type conversion. Specifically I had a method that should have returned a query with string values, however numeric strings were getting converted to decimal numbers. (For example the string "001" was being converted to number 1.0.) Because I was already using ColdSpring to generate the proxies I decided to put together a JSONUtil based ColdSpring advice component to handle the serialization. The advice turned out being so handy I thought I'd package it up and include it in the JSONUtil release.

[More]

Comments
Tim's Gravatar Found your JSONUtil script to use on a CF7 instance we have. Thanks for the script. One issue -- you spelled "deserializeJSON" wrong -- line 20 says <cfset this.deserialzeJSON = deserializeFromJSON />

Thought youd like to know.
# Posted By Tim | 4/15/10 12:30 PM
Andrew's Gravatar I have really liked the JSONUtil. I think I ran into a problem though. When I was serializing a query and then later deserializing, it would return the object mapping instead of the query even though I had the second parameter as false. I looked at the query data and it was deserializing correctly until it hit a column that has "[" or "]" in the query cell value.
Once I converted the characters to parenthesis to test, it worked correctly. In the end, I could use serializeToJSON, but to deserialize it correctly, I had to use the built-in CF deserializeJSON function.

I am not sure if this is a bug or not.
# Posted By Andrew | 3/8/11 4:51 PM
Nathan Mische's Gravatar Thanks Andrew, I will have to take a look at this.
# Posted By Nathan Mische | 3/23/11 11:23 AM
Nathan Mische's Gravatar @Andrew - JSONUtil 1.2 has been release to address this issue. Please get the latest from RIAForge.
# Posted By Nathan Mische | 3/24/11 4:25 PM
essay corrector's Gravatar The coldfusion server will automatically generate documentation for a component if you navigate to its url and insert the appropriate code within the component's declarations.
http://www.essaycorrector.com/ essay corrector
# Posted By essay corrector | 7/16/13 4:44 PM
Mary Jo Sminkey's Gravatar This is a nice piece of work but I did find it unusable in situations where you have a lot of data to loop over and serialize. I was finding CF took 15+ minutes to loop over about 2000 rows of data and serialize using it, versus the CF function taking just milliseconds. Ultimately I had to stick with hacks to correct the couple of fields that CF doesn't serialize properly (typically numbers appearing in a string field). Just wanted to post a warning to anyone looking to use this that it's only appropriate for small amounts of data and you should always test custom libraries for execution time issues.
# Posted By Mary Jo Sminkey | 4/28/16 12:37 AM
BlogCFC was created by Raymond Camden. This blog is running version 5.8.001.