public static void Main()
Type generic = typeof(CustomJson<>);
Type specific = generic.MakeGenericType(typeof(TestClass));
MethodInfo ci = specific.GetMethod("Deserialize");
var res = (TestClass) ci.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; }