2

I tried to serialize my qooxdoo-object to JSON but I always get a 'too much recursion'-errormessage (in Firebug-console) if I try the following:

qx.util.Serializer.toJson(this.getGameData())

Also .toNativeObject-function throws this error. The API-manual is very thin for this: http://www.qooxdoo.org/current/apiviewer/#qx.util.Serializer

Does anybody have a working example for me or a suggestion what could be the reason for this?

Thank you and greetings

Ricky
  • 45
  • 6

1 Answers1

3

One of your objects must have a property or similar which refers to an object which has already been serialised - there's nothing wrong with using qx.util.Serializer, but if you give it an object which has recursive references you will get a recursion error.

You can use the Qooxdoo Playground (http://www.qooxdoo.org/devel/playground/) to create an example of your problem so that others can help diagnose you problem; when you can reproduce it, use the "Shorten URL" button to create a tinyurl link.

Here's a working example of qx.util.Serializer, you can copy & paste it into the playground (SO wont let me use tinyurls :( )

qx.Class.define("abc.MyClass", {
  extend: qx.core.Object,

  properties: {
    alpha: {
      init: null,
      nullable: true
    }
  }
});

var my = new abc.MyClass();
my.set({ alpha: 1 });
this.debug(qx.util.Serializer.toJson(my));


/* ******************************
 * Show the log by clicking the "Log" button in the toolbar to see the output
 */
johnspackman
  • 980
  • 4
  • 10
  • Thanks for your example, John, and sorry for my late answer. I didn't get an alert from SO that somebody answered and saw this just by random. I got it working now. The problem was indeed some recursion error. In qooxdoo there is not problem when a child-object has a reference to its parent object but the serializer seems to don't like it. Another issue I found out is when using objects that has properties of another type of complex object. There I had to pass a property with the current classname of the object that gets stored within the json. This I need in the delegate to marshal. – Ricky Nov 21 '16 at 21:09