When trying to save some data about the game world in a file using JSON, I get that good ol' JSON circular reference error. Is there a way to save circular data types? Also, I'm running this with node.js, not inside a browser.
Basically, over time, the player gets some units. These units are saved to a list inside the player object, but are given the player himself as an argument, so they know who's their owner. Something like this:
Player = function()
{
this.power = 0
this.units = [new Unit(this)];
}
Unit = function(owner)
{
owner.power++;
}