Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/json/15.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在C#中进行System.Web.Script.Serialization?_C#_Json_Javascriptserializer_System.web_Downloadstring - Fatal编程技术网

如何在C#中进行System.Web.Script.Serialization?

如何在C#中进行System.Web.Script.Serialization?,c#,json,javascriptserializer,system.web,downloadstring,C#,Json,Javascriptserializer,System.web,Downloadstring,如何在C#modern UI中实现这一点 var url = "http://ajax.googleapis.com/ajax/services/feed/load?q=http%3A%2F%2Fwww.digg.com%2Frss%2Findex.xml&v=1.0"; var wc = new WebClient(); var rawFeedData = wc.DownloadString(url); //You can use System.Web.Script.Serializ

如何在C#modern UI中实现这一点

var url = "http://ajax.googleapis.com/ajax/services/feed/load?q=http%3A%2F%2Fwww.digg.com%2Frss%2Findex.xml&v=1.0";
var wc = new WebClient();
var rawFeedData = wc.DownloadString(url);

//You can use System.Web.Script.Serialization if you don't want to use Json.NET
JavaScriptSerializer ser = new JavaScriptSerializer();
FeedApiResult foo = ser.Deserialize<FeedApiResult>(rawFeedData);

//Json.NET also return you the same strong typed object     
var apiResult = JsonConvert.DeserializeObject<FeedApiResult>(rawFeedData);
var url=”http://ajax.googleapis.com/ajax/services/feed/load?q=http%3A%2F%2Fwww.digg.com%2Frss%2Findex.xml&v=1.0";
var wc=新的WebClient();
var rawFeedData=wc.DownloadString(url);
//如果不想使用Json.NET,可以使用System.Web.Script.Serialization
JavaScriptSerializer ser=新的JavaScriptSerializer();
FeedApiResult foo=ser.反序列化(rawFeedData);
//Json.NET还返回相同的强类型对象
var apireult=JsonConvert.DeserializeObject(rawFeedData);

它在WebClient和
System.Web.Script.Serialization

中给了我一个错误,我找到了如何使它工作的方法。
我不知道他们为什么会把事情搞得一团糟,我甚至不明白为什么,但解决办法如下: 右键单击项目并添加对以下内容的引用:

System.Web.Extensions

然后,您可以通过以下方式添加所需的参考:

using System.Web.Script.Serialization;

这一次它会起作用。(至少这是我在.NET framework 3.5上所做的)

我在中找到了System.Web.Script.Serialization
System.Web.Extensions

1。找不到类型或命名空间名称“WebClient”-2。找不到类型或命名空间名称“JavaScriptSerializer”,可能与4.0中的相关文章重复。