Like JSON.stringify, but doesn't blow up on circular refs