Currently, I am developing a filetree-like object that has a unique structure:
var myObject = {
'name':'foo',
'contains': {'thisObject': myObject,'parentObject': /* the object that contains the current object*/, 'foo':'bar'},
'parent': /* the object that contains the current object*/
}
Although it may seem unconventional, there is a specific purpose behind this design.
This object is determined by the user and can potentially appear like this:
myObject.contains["foo"].contains["bar"].contains["biz"].contains["frt"]...
I am faced with the challenge of saving this structure to the user's computer. Currently, I have been using localStorage along with JSON.stringify()
. However, this approach leads to JSON throwing a Circular Structure Error.
Is there a way to save this structure while still preserving the Circular Structure? Are there better alternatives than using localStorage/JSON?