我把一个简单的小例子放在一起,它可以很好地序列化。似乎该错误必须来自我们现在没有的 FileFolder 类的设计中的某个地方。
[TestClass]
public class UnitTest8
{
[TestMethod]
public void TestJasonFileFolder()
{
var folder = new FileFolder();
folder.Folder = new FileFolder { Name = "Parent" };
folder.Name = "Something";
var document = new Document { Folder = folder, Id = 1 };
var test = JsonConvert.SerializeObject(document);
Assert.IsNotNull(test);
}
}
public class Document
{
public int Id { get; set; }
public FileFolder Folder { get; set; }
public FileFolder FolderParent
{
get
{
return this.Folder.Folder;
}
}
}
public class FileFolder
{
public string Name { get; set; }
public FileFolder Folder { get; set; }
}