public static T GetJson <T>(string url, CookieContainer cookieContainer = null, SortedDictionary <string, string> headerValues = null, Encoding encoding = null, X509Certificate cer = null, int timeOut = 10000) { string returnText = RequestUtility.HttpGet(url, cookieContainer, headerValues, encoding, cer, timeOut); JavaScriptSerializer js = new JavaScriptSerializer(); T result = js.Deserialize <T>(returnText); return(result); }
/// <summary> /// GET方式请求URL,并返回T类型 /// </summary> /// <typeparam name="T">接收JSON的数据类型</typeparam> /// <param name="url">The URL.</param> /// <param name="encoding">The encoding.</param> /// <param name="maxJsonLength">允许最大JSON长度</param> /// <returns>T.</returns> public static T GetJson <T>(string url, Encoding encoding = null) { string returnText = RequestUtility.HttpGet(url, encoding); JavaScriptSerializer js = new JavaScriptSerializer(); T result = js.Deserialize <T>(returnText); return(result); }