Serialization pattern to maintain back-references

So if I have a one-to-many relationship between two objects, I can only serialize one way, otherwise I get a cyclical error when using Json.NET.

I want to serialize the objects both ways, so I can navigate up and down the object.

Reading Json.NET's documenation, I came upon the ability to conditionally serialize a C# poco property by adding a shouldSerialize method suffixed by the property name..

Take a manager and and employee class. One manager has many employees. I want employees to backreference managers, but I only want managers to reference employees if the manager is not a property of an employee.

If you use ShouldSerialize this way, then your backreferences won't be backreferences. Employee.Manager will point to a differentManager, not the one that contains the employee in its Employees property.

You should use JsonSerializerSettings.PreserveReferencesHandling instead, which was designed speifically to make cross-links possible and to avoid object duplication.