Serialize and deserialize a self referential class

I have folders which need to be able to contain other folders. Note that there can only be 5 folders nested though, if that helps with a solution. I have succesfully saved it all to an object, but said object seems impossible to serialize. I have tried json and binary formatter, both say no, even when I tell json to ignore the risk of an infinite loop. How can I solve this issue without a complete refactoring?

Solved–answer is to use Odin’s open source serialization took