public static void Main()
Type custom = typeof(CustomJson<>);
Type newInstance = custom.MakeGenericType(typeof(TestClass));
MethodInfo mi = newInstance.GetMethod("Deserialize");
var res = (TestClass) mi.Invoke(null, new object[] { "{Id: 3}" });
Console.WriteLine(res.Id);
public static class CustomJson<T> where T : class, new()
public static T Deserialize(string data)
if (string.IsNullOrEmpty(data))
return Newtonsoft.Json.JsonConvert.DeserializeObject<T>(data);
Console.WriteLine(ex.Message);
public int Id { get; set; }