JSON encodes javascript object graphs with object references and types