Safely serialize a value to JSON without unintended loss of data or going into an infinite loop due to circular references.