I have a complex object graph that I am serializing/deserializing with Json.NET. Some of the objects derive from an abstract class, so in order for the deserialization to wo
In your custom JsonConverter, override CanWrite and return false:
public override bool CanWrite { get { return false; } }
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
{
throw new NotImplementedException();
}
Then you can just throw an exception from WriteJson, since it won't get called.
(Similarly, to get default behavior during deserialization, override CanRead and return false.)
Note that the same approach can be used for JsonConverterJsonConverter that introduces type-safe versions of ReadJson() and WriteJson().