ColdFusion 9 JSON Bug

This one is a doozy. I hope it gets fixed by a hot fix rather than the next “dot” update. Bjorn Jensen gets credit for finding it. I ran into it myself yesterday when working on my blog entry. If you have a CFC that returns numeric data and uses a returnType of numeric, then ColdFusion will throw an error. Here is one example of code that will throw the error:

<cffunction name="getX" access="remote" returntype="numeric"> <cfargument name="id" type="any"> <cfreturn arguments.id> </cffunction>

I then entered this URL to test: http://localhost/test.cfc?method=getx&id=1&returnformat=json. The error was:

java.lang.Double cannot be cast to java.lang.String

The fix is to simply change the returnType to string (or any). You can find more detail (and vote for a fix!) at the public bug tracker: http://cfbugs.adobe.com/cfbugreport/flexbugui/cfbugtracker/main.html#bugId=80375.

Raymond Camden's Picture

About Raymond Camden

Raymond is a developer advocate. He focuses on JavaScript, serverless and enterprise cat demos. If you like this article, please consider visiting my Amazon Wishlist or donating via PayPal to show your support. You can even buy me a coffee!

Lafayette, LA https://www.raymondcamden.com

Comments