Friday, November 30, 2012

New Structure Declaration in ColdFusion 10

In ColdFusion 10 a new structure declaration type is introduced.  This is very similar to JavaScript Object declaration and it is as follows:

<cfscript>
//New Type Structure declaration introduced in ColdFusion 10
request.employee = {
name: "Upendra Roul",
ID: "06-800",
JobTitle: "ColdFusion Developer"
};
writeDump(request.employee);
//If you want to make the structure keys case sensitive then put them
//in double cote or single cote as below
request.employeeCaseSensitive = {
"Name": "Upendra Roul",
"ID": "06-800",
"JobTitle": "ColdFusion Developer"
};
writeDump(request.employeeCaseSensitive);
</cfscript>
view raw gistfile1.cfm hosted with ❤ by GitHub


Here we are using colon as separator between key and value rather than '='. Above I have mentioned keys as case sensitive. This means not case sensitive to ColdFusion but other technology like JavaScript.(If we are returning this structure by any AJAX call)

No comments:

Post a Comment

Followers