Deserialize object via JsonConvert and custom TypeConverter


This question already has an answer here:


As @dbc said it just convert objects that inherit from JsonConverter, below is the code that they use, the default serializer is based on the converters parameter. You should inherit from JsonConverter instead of TypeConverter

public static object DeserializeObject(string value, Type type, params JsonConverter[] converters)
  JsonSerializerSettings serializerSettings;
  if (converters == null || converters.Length <= 0)
    serializerSettings = (JsonSerializerSettings) null;
    serializerSettings = new JsonSerializerSettings()
      Converters = (IList<JsonConverter>) converters
  JsonSerializerSettings settings = serializerSettings;
  return JsonConvert.DeserializeObject(value, type, settings);

public static object DeserializeObject(string value, Type type, JsonSerializerSettings settings)
  ValidationUtils.ArgumentNotNull((object) value, "value");
  JsonSerializer @default = JsonSerializer.CreateDefault(settings);
  if (!@default.IsCheckAdditionalContentSet())
    @default.CheckAdditionalContent = true;
  using (JsonTextReader jsonTextReader = new JsonTextReader((TextReader) new StringReader(value)))
    return @default.Deserialize((JsonReader) jsonTextReader, type);

Need Your Help

C++ crash occur when calling delete on a pointer

c++ pointers runtime-error

I have written a small program using struct and pointers(->). So I have declared an object pointer which point to another object from the same struct. But when ever delete is invoked on the applic...