Serialize Javascript object hierarchies with functions