This question already has an answer here:
I need to build a function to return the deserialized object of a JSON string, the type name is stored in the database:
Type jsonType = Type.GetType(log.JSONClassName);
so I need to do something like this:
var obj = AuditHelper.GetJsonType<jsonType>(log.ObjectJson);
AuditHelper.GetJsonType method:
public static T GetJsonType<T>(string json)
{
var logObject = JsonConvert.DeserializeObject<T>(json);
return logObject;
}
Aucun commentaire:
Enregistrer un commentaire