Adobe 38043740 - ColdFusion Standard - Mac Development Manual page 887

Developing applications
Hide thumbs Also See for 38043740 - ColdFusion Standard - Mac:
Table of Contents

Advertisement

DEVELOPING COLDFUSION 9 APPLICATIONS
Requesting and Presenting Information
If the requested return format is JSON and the function returns a query, ColdFusion serializes the query into a JSON
object in either of the following formats:
• As a JSON object with two entries: an array of column names, and an array of column data arrays.
These entries are returned in the following situations:
• By default
• If you specify an HTTP URL parameter of
• If you use the
cfajaxproxy
of
row
ColdFusion client-side binding and proxy code automatically converts this data into JavaScript that is consumed
directly by HTML grids.
• As a JSON object with three entries: the number of rows, an array of column names, and an object where each key
is a column name and each value is an array with the column data
These entries are returned in the following situations:
• If you specify an HTTP URL parameter of
• If you use the
cfajaxproxy
column
ColdFusion client-side binding and proxy code does not convert column format data into JavaScript that is
consumed directly by HTML grids. However, use this format with the
the returned data by using the column names directly. For example, if a CFC function returns a query with user
data, you get the user names in your JavaScript by specifying values such as userData.firstName[0] and
userData.lastName[0].
For more information, see the SerializeJSON function in the CFML Reference.
Using JSON
JSON (JavaScript Object Notation) is a lightweight JavaScript-based data interchange format for transmission between
computer systems. It is a much simpler format than XML or WDDX, and is an efficient, compact format for
transmitting data required for Ajax applications. ColdFusion Ajax bind expressions that use CFCs tell the CFC
function to send the data in JSON format by including a
automatically handle the JSON-formatted result.
JSON represents objects by using { key : value , key : value... } notation, and represents arrays in standard [ value ,
value... ] notation. Values can be strings, numbers, objects, arrays, true, false, or null. Therefore, you can nest arrays
and objects inside each other. For a detailed specification of the JSON format, see www.JSON.org.
Although ColdFusion Ajax-based controls and the
converting anything to JSON format, other applications can take advantage of JSON format data. Many public feeds
are now available in JSON format. For example, the Yahoo! search interface returns a JSON data set, del.icio.us
provides JSON feeds showing your posts and tags, and Blogger feeds are available in JSON format. You don't have to
use Ajax to display these feeds; use standard ColdFusion tags and functions to display the results.
The following CFML functions support using JSON format in server-side code:
DeserializeJSON
SerializeJSON
IsJSON
queryFormat="row"
tag and call the proxy object's
queryFormat="column"
tag and call the proxy object's
returnformat="json"
cffunction
Last updated 1/20/2012
function with a parameter value
setReturnFormat
function with a parameter value of
setQueryFormat
tag, because you can refer to
cfajaxproxy
parameter in the HTTP request, and
tag interoperate transparently, without you
882

Advertisement

Table of Contents
loading

This manual is also suitable for:

Coldfusion 9

Table of Contents