尝试序列化 Qooxdoo-Object 时出现 'too much recursion' 错误
Getting 'too much recursion' error when trying to serialize Qooxdoo-Object
我尝试将我的 qooxdoo-object 序列化为 JSON,但如果我尝试以下操作,我总是会收到 'too much recursion'-errormessage(在 Firebug-console 中):
qx.util.Serializer.toJson(this.getGameData())
.toNativeObject-function 也会抛出此错误。 API-手册对此非常薄:http://www.qooxdoo.org/current/apiviewer/#qx.util.Serializer
有没有人能给我一个可行的例子或建议这可能是什么原因?
谢谢和问候
你的一个对象必须有一个 属性 或类似的,它指的是一个已经被序列化的对象 - 使用 qx.util.Serializer
没有错,但是如果你给它一个对象,它有递归引用你会得到一个递归错误。
您可以使用 Qooxdoo 游乐场 (http://www.qooxdoo.org/devel/playground/) 创建您的问题示例,以便其他人可以帮助诊断您的问题;当你可以复制它时,使用 "Shorten URL" 按钮创建一个 tinyurl link.
这是 qx.util.Serializer 的工作示例,您可以将其复制并粘贴到 playground 中(所以不会让我使用 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
*/
我尝试将我的 qooxdoo-object 序列化为 JSON,但如果我尝试以下操作,我总是会收到 'too much recursion'-errormessage(在 Firebug-console 中):
qx.util.Serializer.toJson(this.getGameData())
.toNativeObject-function 也会抛出此错误。 API-手册对此非常薄:http://www.qooxdoo.org/current/apiviewer/#qx.util.Serializer
有没有人能给我一个可行的例子或建议这可能是什么原因?
谢谢和问候
你的一个对象必须有一个 属性 或类似的,它指的是一个已经被序列化的对象 - 使用 qx.util.Serializer
没有错,但是如果你给它一个对象,它有递归引用你会得到一个递归错误。
您可以使用 Qooxdoo 游乐场 (http://www.qooxdoo.org/devel/playground/) 创建您的问题示例,以便其他人可以帮助诊断您的问题;当你可以复制它时,使用 "Shorten URL" 按钮创建一个 tinyurl link.
这是 qx.util.Serializer 的工作示例,您可以将其复制并粘贴到 playground 中(所以不会让我使用 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
*/