Transforming a tree back to JSON using tree-model-js

[亡魂溺海] 提交于 2019-12-10 09:35:39

问题


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()?

Currently when attempting JSON.stringify(root) it gives an obvious error about cyclic references (because children contain parents and parents contain children).


回答1:


Use JSON.stringify(root.model) instead.



来源:https://stackoverflow.com/questions/30193137/transforming-a-tree-back-to-json-using-tree-model-js

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!