I am using Newtonsoft.Json to serialize/deserialize objects.
As far as I know a deserialization can not be successful if the class does not have parameterless construct
How can I deserialize the object correctly(maybe overriding Name after creating the object)? Is there a way for strict deserialization?
You can declare another constructor and force Json.Net to use it
public class Dog
{
public string Name;
[JsonConstructor]
public Dog()
{
}
public Dog(string name)
{
Name = name + "aaa";
}
}