On 10/15/2010 02:14 PM, NoahGeroz wrote:
> 
> Hi all,
> 
> I'm trying to get a JSON from an array that holds objects (which themselves
> have member arrays that hold other classes). The hierarchy is this:
> 
> Array [Maps] 
>                |
>            Map      1 - *  Feature Presentations  * - 1 Feature Layer
>                          1 - * Raster Presentations    * - 1 Raster Layer
> 

??? - Was this supposed to be formatted in a way?!

> So 1 Map has two arrays, one each for Feature and Raster Presentations and
> all Presentations have exactly one corresponding layer. Having said that, I
> fail to stringify even the simplest of objects (e.g. a layer object). 
> I use the 
> "qx.util.Json.stringify(layer)"

The recommendation is to use qx.lang.Json, which uses native JSON if
available, else qx.util.Json.

> command but all it does is to try and work out the JSON for a few seconds
> and then spit out the "too many recursions" error (firebug). If I do the
> exact same thing with the orinary JSON command:
> JSON.stringify(layer)
> I do get some output though it doesn't quite match my expectations -> 
> 
> {"$$initialized":true,"$$user_dbTableName":"Hi
> there","$$user_id":1,"$$user_idMandator":13}

Which were your expectations? To get only attributes you defined in your
class map? The problem is that the class map is only an input parameter
to a class factory function, and the actual objects derived from this
class are much richer than the original class map.

> 
> where I set the parameters

properties

> "id", "idMandator" and "dbTableName".
> Any suggestions are much welcome. I have attached the class definition
> below. If there's any other code snippet that's needed, please let me know.
> 
> qx.Class.define("project.RasterLayer", 
> {
>   extend: qx.core.Object,
>   construct : function() 
>   { 
>       
>   },
>    properties :
>   {
>   id:                         { nullable : true, event : "" },
>   idMandator:         { nullable : true, event : "" },
>   fileName:           { nullable : true, event : "" },
>   bands:                      { nullable : true, event : "" }
> 
>   }
> });
> 
> I noticed the discussion about bug 3883 but I only downloaded qooxdoo a
> fortnight back and the bug was closed before then.

Unfortunately, this only concerned the Json marshaller of the data
binding, to the end that qooxdoo objects are simply ignored.

I'm not completely sure, but all that seems to indicate that it is not
feasible to run a qooxdoo object through the standard serializer. A
major issue here seems to be the fact that you are not using simple
member attributes, but properties, and chances are that you are drawing
in half of the property system trying to serialize them.

My recommendation would be to write custom serializers, or
pre-serializers,  that return a JS object like

   memebers : {
      toJSObject : function () {
         return { 'foo' : this.foo, 'bar': this.bar, 'baz' : this.baz }
      }
   }

that can then be run through the Json serializer.

Maybe the RPC authors on the list can say more about it.

T.

------------------------------------------------------------------------------
Download new Adobe(R) Flash(R) Builder(TM) 4
The new Adobe(R) Flex(R) 4 and Flash(R) Builder(TM) 4 (formerly 
Flex(R) Builder(TM)) enable the development of rich applications that run
across multiple browsers and platforms. Download your free trials today!
http://p.sf.net/sfu/adobe-dev2dev
_______________________________________________
qooxdoo-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel

Reply via email to