Simplify Ruby object graphs before serializing.