Coldfusion jsStringFormat issue
Coldfusion jsStringFormat issue
I know there arent a whole lot of coldfusion developers out there, especially coldfusion/datatables users, but I shall give my question a shot.
I am currently using the coldfusion server side processing script from the site and for the most part everything is working great. It was until users started populating with their own data, that I ran into problems with special characters not being escaped when passed into the json string from the query. I know that the jsStringFormat() function is supposed to escape all characters output from each column and row, but I am still getting double quotes and ampersands in my json, which obviously breaks datatables.
Heres is a sample of the json coming through. Notice the ampersand in the first line. It is however escaping the apostrophe in the last line correctly.
[code]
{"sEcho": 1,
"iTotalRecords": 659,
"iTotalDisplayRecords": 13,
"aaData": [
["52","138d 4h 7m","01- Operational","","Replace guest WiFi system @ S&S","In Progress","Work Request",""]
,
["410","85d 4h 7m","04- Support","","NEC phone system audit","In Progress","Work Request",""]
,
["591","27d 4h 7m","04- Support","","Evaluate replacement for retrospect","In Progress","Work Request",""]
,
["628","14d 4h 7m","04- Support","","Conference Call Phone Installation","Waiting on parts","Work Request","Oct 21, 2011"]
,
["624","14d 4h 7m","04- Support",""," Phone move to Shorline Apartment Unit 2","Being Researched","Work Request","Oct 21, 2011"]
,
["68","138d 4h 7m","04- Support","","configure scanner Carl\'s desk","Approved","Work Request",""]
] }
[/code]
I am currently using the coldfusion server side processing script from the site and for the most part everything is working great. It was until users started populating with their own data, that I ran into problems with special characters not being escaped when passed into the json string from the query. I know that the jsStringFormat() function is supposed to escape all characters output from each column and row, but I am still getting double quotes and ampersands in my json, which obviously breaks datatables.
Heres is a sample of the json coming through. Notice the ampersand in the first line. It is however escaping the apostrophe in the last line correctly.
[code]
{"sEcho": 1,
"iTotalRecords": 659,
"iTotalDisplayRecords": 13,
"aaData": [
["52","138d 4h 7m","01- Operational","","Replace guest WiFi system @ S&S","In Progress","Work Request",""]
,
["410","85d 4h 7m","04- Support","","NEC phone system audit","In Progress","Work Request",""]
,
["591","27d 4h 7m","04- Support","","Evaluate replacement for retrospect","In Progress","Work Request",""]
,
["628","14d 4h 7m","04- Support","","Conference Call Phone Installation","Waiting on parts","Work Request","Oct 21, 2011"]
,
["624","14d 4h 7m","04- Support",""," Phone move to Shorline Apartment Unit 2","Being Researched","Work Request","Oct 21, 2011"]
,
["68","138d 4h 7m","04- Support","","configure scanner Carl\'s desk","Approved","Work Request",""]
] }
[/code]
This discussion has been closed.
Replies
Allan
[code]
JSONcomment = REREPLACE(comment.getComment(), "\'", "'", 'all');
writeOutput('"#JSStringFormat(JSONcomment)#"');
[/code]