My question is similar to this question - JSON.NET deserialize a specific property . Except I want to deserialize the whole object but also use a custom method to deserialize a specific property in the class. The way I'm doing it right now is deserializing the whole object, and then calling a custom method again to deserialize a specific property in that object. This works, but I don't think it is very efficient.
public class Foo
{
public int id { get; set; }
public object item { get; set; }
}
object obj = JsonConvert.DeserializeObject(json, typeof(Foo));
//This method is from the previously asked question and it works.
object item = GetFirstInstance<GenericFoo<object>>("item", json);
Foo castedFoo= (Foo)obj;
castedFoo.item = item;
How can I update this code to make it more efficient? Something like ignore item property when the first time the object is getting deserialized?