我对 c# 中的 json 非常陌生。我应该做一个项目并通过 mvc4 api 将我的数据提供给其他同学。因此,我也应该能够使用其他 api。
由于我真的不知道如何将请求的结果解析为对象,所以我在这里问。
我一直在请求这样的页面:
string url = "myUrl";
WebRequest request = HttpWebRequest.Create(url);
WebResponse response = request.GetResponse();
StreamReader reader = new StreamReader(response.GetResponseStream());
string urlText = reader.ReadToEnd();
该请求的结果如下:
[{"Id":1,"Whose":1,"ReservedUserId":null,"ReservedBy":null,"ReservedSince":null,"City":"Gent","Street":"Sleepstraat","Number":12,"PostalCode":9000,"DateAdded":"2012-12-28T00:00:00","Description":"Momenteel geen omschrijving van dit pand","ContractLength":"12 maand","Surface":12,"MonthPrice":350,"AvailableSince":"2012-12-28T00:00:00","Rooms":2,"Maintenance":"Goed","Equipment":"Niet gemeubeld","Smokers":false,"Animals":false,"Housemates":2,"Toilet":"Gedeeld","Kitchen":"Gedeeld","Shower":"Gedeeld","Internet":"Ja, Telenet","Included":"Gas & Elektriciteit","Guarantee":350,"ContactEmail":"kotbaas@baas.com","ContactTel":"0936001234"}]
我怎样才能轻松地将其转换为 ac# 对象,以便我可以使用它的属性?
亲切的问候