• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

coldfusion json truncates leading zeroes

Guest
Dec 13, 2010 Dec 13, 2010

Copy link to clipboard

Copied

Hi All -

I am using jquery jqgrid with Coldfusion. I have a cfc whose return format is JSON. I have a database column of type varchar, but it returns values which starts with zeroes. On displaying data, the leading zeroes are truncated. I verified in firebug, the JSON response itself is cutting off the leading zeroes.

Any suggestions or thoughts on this?

TOPICS
Advanced techniques

Views

1.7K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Dec 13, 2010 Dec 13, 2010

Copy link to clipboard

Copied

Make a test copy of your cfc.  Start invoking it and dumping data until you can see the line of code that is stripping away your zeros.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Dec 13, 2010 Dec 13, 2010

Copy link to clipboard

Copied

I am actually just now having the same problem. I don't know of a good solution so I put in a conditional to add a space if the string starts with zero.

<cfif left(.getValue.value,1) EQ '0'>

    <cfset arrayAppend(row["cell"], ' #local.getValue.value#')>

<cfelse>

    <cfset arrayAppend(.row["cell"], local.getValue.value)>

</cfif>

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Dec 13, 2010 Dec 13, 2010

Copy link to clipboard

Copied

LATEST

If you are using CF 9.0 there was a documented bug that has been fixed in Adobe® ColdFusion® 9.0 Update 1:

ID

Area

Bug Description

82706

AJAX Plumbing

When you use  serializeJSON or   deserializeJSON, data type conversion occurs  automatically. For example,   000001 is converted to numeric 1.

I know that there are new bugs introduced with Updater 1 so it would probably be wise to get the ColdFusion 9.0.1 Cumulative Hot Fix 1 also. As always, test the updates before using in production.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation