Coldfusion's SerializeJson Sucks!

If I recall correctly CFML is a typeless language. I mean we can really all agree that Coldfusion is typeless right?

Ok now that we have that out of the way lets talk about Adobe's implementation of serializejson(). Serializejson is simply trying to be too damn smart for its own good.

Listen I don't want you to frig with my data, I want you to take my structured data, be it query, structure, or array, or whatever, and simply convert that structure into its JSON equivalent. Don't try to parse my dates, numbers or what not, or even try to. Just take what I give you and simply covert the data from one structure to the other mmmkay?

Since when is 9999999999999999E+10 equal to 9.999999999999999E25. Ok mathematically they are, but did I ask you to be smart and do math? NO, I don't think I did!

Either provide me with enough options that I can influence how numbers and dates are handled or do what Railo does and output everything as strings.

/rant off

10 Comments to "Coldfusion's SerializeJson Sucks!"- Add Yours
Nic Tunney's Gravatar ColdFusion isn't typeless, it's loosely typed ;)
# Posted By Nic Tunney | 11/23/10 8:33 AM
Henry's Gravatar Have you checked JSON's doc? CF is doing the right thing.
# Posted By Henry | 11/23/10 10:00 AM
Jason Dean's Gravatar What version are you using? Adobe made a lot of changes between CF8 and CF9.0.1 to improve the JSON serialization.

It's a trickier beast than you imply it is. If you look at the way some other languages are handling it, you can see that it is not as simple as just saying doWhatIThinkYouShould().
# Posted By Jason Dean | 11/23/10 12:29 PM
Scott Stroz's Gravatar You really think that outputting everything as a string is the 'right' way to handle it?
# Posted By Scott Stroz | 11/23/10 12:31 PM
Russ S.'s Gravatar SerializeJSON is nice to have, but sometimes it just does things differently than you'd expect.
I've had to go back to CFJSON ( for a number of projects, especially anything that needs to respond consistently across multiple versions and vendors of CF.
# Posted By Russ S. | 11/23/10 12:35 PM
Scott Stroz's Gravatar Doing it differently than you expect != doing it wrong

maybe its your expectations that are wrong?
# Posted By Scott Stroz | 11/23/10 12:37 PM
Sam Farmer's Gravatar What you are asking for is not what de/serializing JSON is for. The idea is to keep the type be it a structure, date, number, boolean, etc. It might have use but to say ColdFusion serializeJSON sucks is missing the point.
# Posted By Sam Farmer | 11/23/10 12:58 PM
Raymond Camden's Gravatar To be picky on what Jason said - JSON serialization also changed _post_ 901. You want to have 901 and the Cumulative Hot Fix applied.
# Posted By Raymond Camden | 11/23/10 1:33 PM
Kai Koenig's Gravatar Sorry Gary, but you're imho wrong with this. ColdFusion 9.01 (+ CHF) is delivering JSON serialisation/deserialisation as close to the JSON standards as it gets and it was a bit of an effort involved to get it there.

Maybe instead of ranting about the CF way of doing things sucks you could write an additional post a) outlining which CF setup you run and b) why exactly CF is not doing right in your opinion. Maybe a bunch of test cases, scenarios in code.

# Posted By Kai Koenig | 11/23/10 1:58 PM
rgmoon's Gravatar CFML is very complicated language and it is very hard to understand. The right description you have given here for this language. I will try to understand the whole concept and waiting for next similar post.
# Posted By rgmoon | 1/6/12 3:09 AM

Powered By Railo


Subscribe via RSS
Follow garyrgilbert on Twitter Follow me on Twitter
Or, Receive daily updates via email.


adobe air ajax apple cf community cfml coldfusion examples ext flash flex google javascript jquery max2007 max2008 misc open source programming railo software technology ui

Recent Entries

No recent entries.


An Architect's View
Rey Bango

Wish List

My Wish List