I'm using JsonConvert
to serialize and deserialize objects from classes like this:
public class DbBulkRequest
{
public DbEntity[] Updates { get; set; }
}
public class DbEntity
{
public string Name { get; set; }
public object Dto { get; set; }
}
When I deserialize Dto
, I get an object of type JObject
. At the time of deserialization, I want to create strongly typed objects based on Dto
. I can create the objects; however, I don't know of a good way of populating their properties. The best I've found is this cheeseball approach:
MyEntity e = JsonConvert.DeserializeObject<MyEntity>(JsonConvert.SerializeObject(dto));
What would be a more efficient solution?