One approach is to use the object as the outermost container, using the keys of the object as identifiers:
var objs = {
obj1: { link: "obj2" },
obj2: { link: "obj1" }
}
Then you can only follow links with property searches:
var o1 = objs["obj1"];
var o2 = objs[o1.link];
And this will convert to JSON without any conversion
source
share