ServiceStack/ServiceStack — Issue #90: JsonSerializer is unable to serialize a self referencing child property
Author: niemyjski
Created: 2012-02-02 20:58:35+00:00
State: open

Here is the class definition:

public class TestClass
{
public TestClass()
{
}
public string Description { get; set; }
public TestClass Inner { get; set; }
}

When I try and post this type via JsonServiceClient I receive the following NullReferenceException.

System.NullReferenceException : Object reference not set to an instance of an object.
at ServiceStack.Text.JsonSerializer.SerializeToStream(T value, Stream stream) in C:\src\ServiceStack.Text\src\ServiceStack.Text\JsonSerializer.cs: line 136
at ServiceStack.ServiceModel.Serialization.JsonDataContractSerializer.SerializeToStream(T obj, Stream stream) in JsonDataContractSerializer.cs: line 71
at ServiceStack.ServiceClient.Web.ServiceClientBase.SendRequest(String httpMethod, String requestUri, Object request) in ServiceClientBase.cs: line 301
at ServiceStack.ServiceClient.Web.ServiceClientBase.Send(String httpMethod, String relativeOrAbsoluteUrl, Object request) in ServiceClientBase.cs: line 370