tracker issue : CF-4199525

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

CFC Returning a string with an E and surrounded by numbers as a JSON numeric value (without quotes)

| View in Tracker

Status/Resolution/Reason: Closed/Withdrawn/Duplicate

Reporter/Name(from Bugbase): JJ BLODGETT / JJ BLODGETT ()

Created: 08/23/2017

Components: Language, CF Component

Versions: 2016,11.0

Failure Type: Incorrectly functioning

Found In Build/Fixed In Build: 2016.0.03.300466 / NA

Priority/Frequency: Major / All users will encounter

Locale/System: English / Win 2012 Server x64

Vote Count: 4

Problem Description: 
CFC returns a structure as JSON to browser. If any individual keys have a value that is all numeric with a single "e" (case insensitive) in any position other than the first or last, the JSON that is returned will not be enclosed in quotes. So CF appears to be treating it as a scientific notation. This becomes a problem by anything that consumes the JSON since it thinks the value is a number. For example, browsers treat "2E2" as 200, and any "larger" scientifically notated numbers as "Infinity."

Steps to Reproduce: Create a CFC with a function that returns a structure as JSON. Create a string such as "2E2", "1234E56", etc. Then consume the function in a browser.

Actual Result: CF structure of {"test"="2E2"} is sent to browser in JSON as {"test": 2E2};
CF structure of {"test"="1234E56"} is sent to browser in JSON as {"test": 1234E56}

Expected Result: {"test"="2E2"} should be {"test": "2E2"};
{"test"="1234E56"} should be {"test": "1234E56"};

Any Workarounds: Other than adding characters to the string to make it not appear to be scientific notation, we are not aware of any workarounds. But in our case, we are dealing with Encrypted strings in HEX so adding characters breaks the ability to Decrypt the strings correctly.

Attachments:

  1. August 23, 2017 00:00:00: testInfJson.cfm

Comments:

This also happens with SerializeJSON even though it was supposedly fixed in CF10 (Previous Bug Report: CF-3695627)
Comment by JJ B.
394 | August 23, 2017 02:47:08 AM GMT
We are having this issue as well.
Vote by Daniel H.
396 | August 23, 2017 11:36:12 PM GMT
Another side effect of this is if it goes through several layers of this. Coldfusion ends up generating JSON where it puts infinity in the json without any quotes. Those generating invalid json. I've attached a CFM demostrating this issue. This is a problem for us, as we're updating some json documents and sending them through, and it ends up generating invalid JSON.
Comment by Daniel H.
395 | August 23, 2017 11:41:15 PM GMT