JSON.NET: JsonCreationConverter working WriteJson implementation
c#, json.net, serialization
Solution
Try overriding the `CanWrite` property getter in the converter so that it returns `false`. This will prevent the converter from being used during serialization.
public override bool CanWrite
{
get { return false; }
}
Problem
From this answer I have class `JsonCreationConverter<T>` and some implementations for concrete types. But this abstract class misses the implementation of `WriteJson` method. Over the internet I find the code: ``` public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) { //use the default serialization - it works fine serializer.Serialize(writer, value); } ``` But this code ends up with StackOverflowException as it calls itself all the time (of course). Other solutions were for concrete objects implementations with serializing all the values one by one. I really want to avoid it, just want to use default serialization, which is OK for me. Just to avoid calling my JsonConverter for serialization. I need it only for deserialization. Is it possible? How?