I am trying to generate JSON from a query. All this seems to be too much grinding it out.
string function getJSON() output="false" {
var result = "[";
var myrow = 0;
for(var row in this.qryLocation) {
myrow++;
result &= "["
& row.LocationID & ','
& '"' & row.Address & " " & row.City & '",'
& '"' & row.formatted_CreateDate & '"'
& ']'
& myRow < this.qryLocation.recordcount ? ',' : '';
} // end for-in query
return result & "]";
}
All this seems very hard to read, especially making sure that the last row does not get an extra comma.