tracker issue : CF-3043044

select a category, or use search below
(searches all categories and all time range)
Title:

Bug 85760:(Watson Migration Closure)SerializeJSON treats a the string "+1234567890" (such as phone numbers) as a number which then throws an error when you call DeSerializeJSON

| View in Tracker

Status/Resolution/Reason: Closed/Withdrawn/

Reporter/Name(from Bugbase): John Whish / John Whish (John Whish)

Created: 01/10/2011

Components: Language, Functions

Versions: 9.0.1

Failure Type: Unspecified

Found In Build/Fixed In Build: Cumulative Hotfix 1 (CHF1) /

Priority/Frequency: Major / Unknown

Locale/System: English / Platforms All

Vote Count: 1

Duplicate ID:	CF-3632972

Problem:

SerializeJSON treats a the string "+1234567890" (such as phone numbers) as a number which then throws an error when you call DeSerializeJSON. 
Method:

SerializeJSON on CF9.01 patched with the Cumulative Hotfix 1 (CHF1) for ColdFusion 9.0.1. Here's a quick example:<cfset foo = {telephone="123456789"}><cfset bar = SerializeJSON(foo)><cfdump var="#IsJson(bar)#"><cfset foo = {telephone="+123456789"}><cfset bar = SerializeJSON(foo)><cfdump var="#IsJson(bar)#"><cfset foo = {telephone=" +123456789"}><cfset bar = SerializeJSON(foo)><cfdump var="#IsJson(bar)#"><cfset foo = {telephone="+123456789 "}><cfset bar = SerializeJSON(foo)><cfdump var="#IsJson(bar)#"><cfset foo = {telephone="+ 123456789"}><cfset bar = SerializeJSON(foo)><cfdump var="#IsJson(bar)#"><cfset foo = {telephone=["+123456789"]}><cfset bar = SerializeJSON(foo)><cfdump var="#IsJson(bar)#"><cfset foo = {telephone=[" +123456789 "]}><cfset bar = SerializeJSON(foo)><cfdump var="#IsJson(bar)#"><cfset foo = {telephone=["+123456789 "]}><cfset bar = SerializeJSON(foo)><cfdump var="#IsJson(bar)#">The output I get when I run the above code returns:YES NO YES NO YES NO YES NOLooking a bit closer at the string that SerializeJSON is creating I noticed that ColdFusion treats "+123456789" as a numeric value and therefore does not wrap it in quotes when generating the JSON. To demonstrate here is another bit of test code.<cfset foo = {telephone1="+123456789",telephone2=" +123456789",telephone3="+123456789 "}><cfset bar = SerializeJSON(foo)><cfdump var="#bar#"><cfdump var="#IsJson(bar)#"><cfdump var="#DeSerializeJSON(bar)#">When I run this I get:{"TELEPHONE1":+123456789,"TELEPHONE2":" +123456789","TELEPHONE3":+123456789 } NOThe web site you are accessing has experienced an unexpected error.Please contact the website administrator. Error Occurred While Processing RequestJSON parsing failure at character 15:'+' in {"TELEPHONE1":+123456789,"TELEPHONE2":" +123456789","TELEPHONE3":+123456789 } The error occurred in C:\xampp\htdocs\scratchpad\index.cfm: line 1210 : <cfdump var="#bar#">11 : <cfdump var="#IsJson(bar)#">12 : <cfdump var="#DeSerializeJSON(bar)#">So there you go, looks like a bug to me and I'll be adding it to the bug tracker unless anyone else has already reported it.I tried removing chf9010001.jar from my lib\updates folder and restarting ColdFusion and everything works as expected, so this bug seems to have been introduced in the HotFix.
Result:

Error Occurred While Processing RequestJSON parsing failure at character 15:'+' in {"TELEPHONE1":+123456789,"TELEPHONE2":" +123456789","TELEPHONE3":+123456789 }

----------------------------- Additional Watson Details -----------------------------

Watson Bug ID:	3043044

External Customer Info:
External Company:  
External Customer Name: John Whish
External Customer Email: 4B9370D7448AB8BF9920157F
External Test Config: 01/10/2011

Attachments:

Comments: