码迷,mamicode.com
首页 > Web开发 > 详细

根据URL接口地址获取JSON数据

时间:2015-02-03 13:04:25      阅读:173      评论:0      收藏:0      [点我收藏+]

标签:

       //根据URL回发地址获取用户json数据
        private string GetJsonByUrl(string url)
        {
            System.Net.HttpWebRequest request = (System.Net.HttpWebRequest)System.Net.HttpWebRequest.Create(url);
            System.Net.HttpWebResponse response = (System.Net.HttpWebResponse)request.GetResponse();
            System.IO.Stream responseStream = response.GetResponseStream();
            System.IO.StreamReader sr = new System.IO.StreamReader(responseStream, System.Text.Encoding.GetEncoding("utf-8"));
            string responseText = sr.ReadToEnd();
            sr.Close();
            sr.Dispose();
            responseStream.Close();
            string jsonData = responseText;
            return jsonData;
        }

根据URL接口地址获取JSON数据

标签:

原文地址:http://www.cnblogs.com/anyben/p/4269633.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!