Skip navigation
David Aden
Currently Being Moderated

Problem with serializeJSON -- truncates embedded objects

Apr 15, 2012 7:59 AM

It appears that serializeJSON will truncate embedded arrays of objects. This came up while refactoring an ajax app and it took a while to trace down as I thought I must have done something wrong in refactoring somewhere.


I eventually found out that the implicit serialization that was being done by a "remote" method of an object that has a property containing an array of other objects seems to truncate anything more than the first two elements of the embedded array.


Here are some files that demonstrate the problem running the dev version 9.01 on a Windows 7 desktop.


Index.cfm generates an array of objects, then adds the array to a property of ttl_message object and serializes both the array itself (which works fine) and the ttl_message object (which results in the first two elements of the embedded array being serialized but the second two being set to "").




component {







          this.ormEnabled = false;





component ttl_Assignment


          persistent="false" {


          property string name;


  property string description;


          function init( obj ) {

                    if( IsDefined("obj") ) {

                              for( var p in obj) {

                                        variables[p] = obj[p];









component ttl_Message


          persistent="false"   {


          property string name;


    property any payload;



          public any function init( string name){

                    if( isStruct( "name" ) ) {


                    } else {

                              setName( name );



                    return this;







          // make some new assignments

          a = new ttl_Assignment( {"name"="foo","description"="descript here"} );

          b = new ttl_Assignment( {"name"="boo","description"="descript 2"} );

          c = new ttl_Assignment( {"name"="boo","description"="descript 3"} );

          d = new ttl_Assignment( {"name"="boo","description"="descript 4"} );


          // put them into an array

          arr = [a,b,c,d];


          // create a message

          mess = new ttl_Message( "here is the message" );


          // add the array to the message

          mess.setPayload( arr );


          writedump( arr );                                                            // dump the array

          writedump( serializeJSON(arr) );                    // serialize the array

          writedump( mess );                                                            // dump the message

          writedump( serializeJSON(mess) );                    // serialize the message



  • Currently Being Moderated
    Apr 23, 2012 2:08 AM   in reply to David Aden

    It is a known bug (ID=83836). Cumulative Hotfix 2 of ColdFusion 9.0.1 addresses this issue, among others.

    Mark as:
  • Currently Being Moderated
    Apr 23, 2012 4:00 PM   in reply to BKBK

    Here is my experience before and after Hotfix 2:

    1. Still see similar error in ORM as the original poster described (nested objects can only serialize the first two, the rest are serialized as empty objects)

    2. The objects are kind of correctly serialized as empty objects instead of empty string (behavior before hotfix 2)

    Mark as:
  • Currently Being Moderated
    Apr 24, 2012 1:39 AM   in reply to GuogangHu

    My advice to David is to install the hot fix and find out for himself. In any case, the hot fix resolves plenty of other issues besides, some of them quite serious.

    Mark as:
  • Currently Being Moderated
    Apr 24, 2012 10:26 AM   in reply to BKBK

    Glad to hear prompt reply. We did have hot fix 2 installed, and saw some improvements. There is still some problem getting only the first two elements in array JSON serialized. And here is what we found after some try and error:

    1. only applicable to JSON serialization (CFDUMP can show the whole data without any problem);

    2. only have problem with ORM returns (which are java objects), we created Coldfusion structs similar to the original post, and that data can be serialized correctly in hotfix 2

    3. only happens when the array is embedded in another parent object. Top level array can be serialized correctly

    Mark as:
  • Currently Being Moderated
    Apr 25, 2012 2:50 PM   in reply to GuogangHu

    I'm seeing precisely the same behavior: when serializing ORM objects, only the first 2 elements in an embedded array have data, while additional array elements are rendered as "{}".

    I know there is a bug filed for this already (, but am hoping someone has ideas for workarounds.

    Mark as:
  • Currently Being Moderated
    Apr 25, 2012 9:26 PM   in reply to existdissolve apparently still an issue in CF10. *sigh*

    Mark as:
  • Currently Being Moderated
    Apr 26, 2012 12:38 AM   in reply to existdissolve

    existdissolve wrote:

  apparently still an issue in CF10. *sigh*

    It is sad to hear that the issue has resurfaced in ColdFusion 10. I have voted for it in the bugbase.

    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points