JSON data rendering, how to get quotes not escaped?

I'm having another problem. I'm trying to get jqGrid working using
its built-in ajax call, with JSON. In my handler, I return the data


jqGrid's screwy requirements want the data as a comma-delimited list,
rather than a key/value pair. And in the examples on the jqGrid site,
they show the values as being quoted (think QuotedValueList). But
when I format the data, it comes through as escaped (backslashes
before each quote). Without quotes, the entire list gets quoted. And
what I'm seeing now, and I suspect it maybe related, is the data
itself is showing up one character per column. For example:

4 | 4 | 0 | , | B | a | r | b | NaNaNaN (etc)

The vertical bars represent the individual columns in the grid.

Is there a way to get ColdBox to NOT escape the quotes?


This is more of the ColdFusion JSON parser doing it. I think you might do things manually for this. I am not sure as I am not familiar with jqGrid. ANybody?

I use jqGrid all the time without any issues.

My response includes escaped quotes

Example response

{"ROWS":[["1","<a href=\"someURL\" >Manage<\/a>","<a href=\"someURL\" >Edit<\/a>","some data"]],"PAGE":"1","RECORDS":"5","TOTAL":"1.0"}

Rows needs to be an array of data, and the gridData needs to be a struct.

rc.gridData = {total=totalPages,page=currentpage,records=totalCount,rows=arrayofRows};


Hope that helps.

Curt Gratz
Computer Know How

Yeah that's exactly how I'm doing it. Here's my code... very similar:

  <cffunction name="StructToValueList" access="public" output="false"
    <cfargument name="obj" type="struct" required="yes">
    <cfargument name="keys" type="string" required="no"

    <!--- This function takes a structure and basically rips the keys
out of it, making it a list. --->

    var count = "";
    var myArr = ArrayNew(1);

    <cfloop index="count" list="#arguments.keys#">
       <cfif Len(arguments.obj[count]) gt 0>
        <cfset ArrayAppend(myArr, '#arguments.obj[count]#')>
        <cfset ArrayAppend(myArr, 'XXX')>

    <cfreturn ArrayToList(myArr)>


<cfloop index="temp.count" from="#temp.startrow#" to="#temp.endrow#">
  x = x + 1;
  temp.cellArr[x] = StructNew();
  temp.cellArr[x].id = temp2.result[temp.count].contact_id;
  temp.cellArr[x].cell =

ret = {total=temp.totalPages, page=temp.page,
records=temp2.survey.recordcount, rows=temp.cellArr};


(note: I edited out some records to save space, and changed the names
to protect the innocent). This example has "XXX" substituted for
empty values, just as a test. But note that the quotes aren't around
each value, it's around the whole string.

What am I doing wrong?? This is maddening. :slight_smile:


You are returning an array of structs,

You need an array of arrays

Data like this
ar = arraynew(1);

ar[1] = [ 'col1 data row 1','col2 data row 1','col3 data row 1' ];
ar[2] = [ 'col1 data row 2','col2 data row 2','col3 data row 2' ];

returns this, which jqGrid can handle...
{"ROWS":[["col1 data row 1","col2 data row 1","col3 data row 1"],["col1 data row 2","col2 data row 2","col3 data row 2"]],PAGE":"1","RECORDS":"5","TOTAL":"1.0"};

AHA! That was it. Thanks! I got it working.