I have a database structure that has several referential loops. When I try to serialize this with JsonSerializer I get:
Self referencing loop detected with type: Path 'employee.EmployeeStockAssignment[0].Person.Department.Company.Departments'.
If I set ReferenceLoopHandling = ReferenceLoopHandling.Ignore
this instead gives a stackoverflow.
Is there anyway do this without creating a new object?
EDIT: To expand on WHY I don't want to create a new object ( or modify the existing one ). The object tree's I'm working on are fairly complex, and if I for some reason forget to create a new object/modify the existing one 100% correct, this will actually crash the web server (together with ReferenceLoopHandling.Ignore that is). For now I'm casting everything to anomyous objects before I serialize, and I'm running ReferenceLoopHandling.Error in case I forget somewhere.