ASP.NET JSON Self Referencing Properties

In object-oriented languages, an object can hold a reference to itself in a property, and there's no problem with that. However, when you go to serialize that object, you run into issues.

An object with a self-referencing property that loops back to itself would cause an infinite loop and crash when trying to serialize it. Here's how to avoid the error in ASP.NET.

I'd recommend against the idea in the first place, opting instead for simple data types, but this is here if you need it.

View code on GitHub


Popular posts from this blog

DotNet CLI

Nullable reference types

C# Static Constructors