Example #1
0
        //GET
        public ActionResult WeatherForJson()
        {
            string response = HttpWebResponseUtility.Get("https://www.tianqiapi.com/api?version=v1&cityid=101010100");
            //此时response的字符串有很多\,这是C#自动转义的,不用处理
            //string s = response.Replace(@"\","");
            JObject jb   = (JObject)JsonConvert.DeserializeObject(response);
            string  city = jb["cityid"].ToString();//这里是尝试使用json的序列化效果

            //return Json(jb, JsonRequestBehavior.AllowGet);
            //return Content(response);//页面返回json字符串
            return(View());
        }