ColdFusion 10.0  -  Bug 3689989

Created on Tuesday, January 7, 2014

Login for more options


serializeJson not cleaning most of the first 31 characters in the ASCII table.


Problem Description: Invalid JSON data is being created from data extacted from MSSQL tables. chr(1) to chr(7) + chr(11) + chr(14) to chr(31) - Possibly others??

Steps to Reproduce:
See attachment
<!--- chr(1) to chr(7) + chr(11) + chr(14) to chr(31) --->
<cfset char_val = chr(1) >

<cfset tblTemp = queryNew("character", "VarChar") >

<cfset QueryAddRow(tblTemp) >
<cfset querySetCell(tblTemp, "character", "ascii character after here.. " , 1) >

<cfquery dbtype="query" name="ascii_data" >
select [character] + '#char_val#' + ' End' as [character]
from tblTemp

<cfset jsonData = serializeJSON(ascii_data) >

<cfcontent type="text/html; charset=utf-8" />


<!doctype html>
<meta charset="utf-8" />



JSON Data:


View the JavaScript Console:

<script type="text/javascript">

var sJSON = JSON.parse("#JsStringFormat(jsonData)#");




Actual Result: Invalid JSON (parsererror SyntaxError: JSON.parse: bad control character in string literal)

Expected Result: Valid JSON

Any Workarounds: Loop the data to clean using a udf function. It would be better if this was dealt with once at the serializeJson function.

Test Configuration

My Hardware and Environment details:
ColdFusion 9 & 10 - Firefox. All platforms.

App Language(s) English
OS Language(s) English
Platform(s) Windows 7 64-bit

Notes (3)

  • Pat Moody

    12:52:57 PM GMT+00:00 Jan 15, 2014

    Unicode characters
    8232 - Line Separator
    8233 - Paragraph Separator
    Break JavaScript code and not the JSON parsing.

  • Pat Moody

    6:53:02 PM GMT+00:00 Jan 13, 2014

    Ben Nadel has just blogged about this issue!
    You will see that there are two further ASCII characters that need dealing with.
    8232 - Line Separator
    8233 - Paragraph Separator

  • Pat Moody

    2:57:49 PM GMT+00:00 Jan 7, 2014

    Bug was discovered from data saved to MSSQL 2008 database Generally SQL string data from nvarchar tables. Characters probably as a result of users copying and pasting data from other systems / PC's / MAC's etc.

Duplicate ID
Reported By Pat Moody


State Closed
Status Fixed


Priority 3-High
Frequency All users will encounter
Failure Type Incorrectly Functioning
Product Area AJAX


Found In Build Final
Fixed In Build

Attachments (0)

No Files Attached

Votes (3)

  • Adam Cameron

    1:20:27 AM GMT+00:00 Jan 15, 2014



  • yujust

    10:32:20 AM GMT+00:00 Jan 14, 2014

    I encountered the same issue.

  • Henry Ho

    6:51:09 PM GMT+00:00 Jan 13, 2014

    encountered the same error. pls fix

Your session has expired! Click to login
Current form data will be preserved