Version 0.2

Corrected the escape function. Unlike XML, JSON does not have a CDATA capability. This makes escaping certain characters a requirement. Just like the toXML.QueryToXML() function there is an argument called 'cDataCols', which is a list of columns that are to use the CDATA element. In toJSON, this argument is used to escape those characters for the columns listed.

Why not use cfjson.cfc?

I tried cfjson.cfc and it is a very good cfc for changing ColdFusion structures to JSON data. In a query it puts all of the values for a column into an array. What I was using is toXML.cfc, which keeps each record's columns together. That is how I write my applications and that is what I am most comfortable using.

toJSON puts each record into an array and then sets name value pairs as "column name" : "value". This creates a larger file than cfjson.cfc. It is still much smaller than XML.

BlogCFC was created by Raymond Camden. This blog is running version 5.5.006. | Protected by Akismet | Blog with WordPress