使用tree-model-js将树转换回JSON [英] Transforming a tree back to JSON using tree-model-js
本文介绍了使用tree-model-js将树转换回JSON的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
是否有一种方法可以将TreeModel转换为JSON字符串。这样它可以存储,然后使用 tree.parse()
重新创建?
Is there perhaps a way in which you can convert a TreeModel to a JSON string. That way it can be stored and then later recreated using tree.parse()
?
目前在尝试 JSON.stringify(root)
时,它会给出一个关于循环引用的明显错误(因为子项包含父项)和父母包含孩子。)
Currently when attempting JSON.stringify(root)
it gives an obvious error about cyclic references (because children contain parents and parents contain children).
推荐答案
使用 JSON.stringify(root.model)
而不是。
这篇关于使用tree-model-js将树转换回JSON的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文