Skip to main content
Inspiring
April 20, 2015
Question

returnformat = JSON

  • April 20, 2015
  • 1 reply
  • 433 views

I have some fields that are varchar, however, they have numbers in them.  JSON does not return them inside quotation marks because it is interpreting it as a number.  Real numbers do not work, either.  Is there a workaround?

<cffunction name="jqgridCP" access="remote" returnformat="json">

I'm trying to populate a cfgrid with data from a cfquery.  The fields that have numbers as data (not all do) but are varchar in the database return empty cells.

It appears to be adding .0 to the numbers.

This topic has been closed for replies.

1 reply

Inspiring
April 20, 2015

Serialization of numeric values

Note: To use this feature, you must install ColdFusion 9 Update 1.

In the previous releases (including ColdFusion 9), serializing an integer using serializeJSON, converts the number to a double. For example, SerializeJSON (123) returns 123.0.

In ColdFusion 9.0.1, the integer is retained in its original format but enclosed within quotes. That is, SerializeJSON (123) returns "123". This is applicable only to positive integers.

The following table gives more examples:

Input

Serialized JSON

10

“10”

012

“012”

10.25

“10.25”

10.25E5

“1025000.0”

10.25E-5

“1.025E-4”

-10

“-10.0”

-10.25

“-10.25”

Note: To remove the quotes in the returned value, for positive integers and integers within quotes, set the jvm argument json.numberasdouble totrue . However, negative integers such as -10 will still be serialized to “-10.0” even if json.numberasdouble=true.