예제 #1
0
        /// <summary>
        /// 【异步方法】异步GetJson
        /// </summary>
        /// <param name="url"></param>
        /// <param name="encoding"></param>
        /// <param name="maxJsonLength">允许最大JSON长度</param>
        /// <typeparam name="T"></typeparam>
        /// <returns></returns>
        /// <exception cref="ErrorJsonResultException"></exception>
        public static async Task <T> GetJsonAsync <T>(string url, Encoding encoding = null, int?maxJsonLength = null)
        {
            string returnText = await RequestHelper.HttpGetAsync(url, encoding);

            return(returnText.DeserializeFromJson <T>());
        }
예제 #2
0
        /// <summary>
        /// GET方式请求URL,并返回T类型
        /// </summary>
        /// <typeparam name="T">接收JSON的数据类型</typeparam>
        /// <param name="url"></param>
        /// <param name="encoding"></param>
        /// <param name="maxJsonLength">允许最大JSON长度</param>
        /// <returns></returns>
        public static T GetJson <T>(string url, Encoding encoding = null, int?maxJsonLength = null)
        {
            var returnText = RequestHelper.HttpGet(url, encoding);

            return(returnText.DeserializeFromJson <T>());
        }