/ Published in: JavaScript
in javascript use, for example: myJsonObject["js007"].firstname + ' ' + myJsonObject["js007"].lastnamename
to return James Bond
to return James Bond
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
<cfscript> function nowhitespace(queryname,uniqueIdColumnName,columnlist,recordcount) { var p=""; var currentrow = 1; p = p & '"RECORDCOUNT":' & recordcount & ',' & '"UNIQUEIDS":['; for (ids = 1; ids lte recordcount; ids = ids+1){ p = p & '"js' & evaluate("queryname." & uniqueIdColumnName & '[' & ids & ']') & '"'; if (ids lt recordcount) {p = p & ',';} else {p = p & '],';} } p = p & '"COLUMNNAMES":[' & listQualify(columnlist,'"') & '],'; for (idx = 1; idx lte recordcount; idx = idx+1) { p = p & '"js' & evaluate("queryname." & uniqueIdColumnName & '[' & idx & ']') & '"' & ':{'; p = p & '"CURRENTROW":' & currentrow & ','; for (idx1 = 1; idx1 lte listlen(columnlist); idx1 = idx1+1){ clmnname = listgetat(columnlist,idx1); p = p & '"' & clmnname & '":'; evalp = evaluate("queryname." & clmnname & '[' & idx & ']'); if (NOT isNumeric(evalp)) {evalp = '"' & JSStringFormat(evalp) & '"';} if (idx1 IS listlen(columnlist)){p = p & evalp;} else {p = p & evalp & ',';} } if (idx NEQ recordcount) { p = p & '},'; currentrow = currentrow + 1; } } idx1 = 1; p = p & '}'; return '{' & p & '}'; } </cfscript>