以下是我的responseFromServer,
{"version":3,"status":"ok","response":{"data":[{"address":"1908 Bull Temple Road","category_ids":[29],"category_labels":[["Community and Government","Education","Colleges and Universities"]],"country":"in","email":"principal@bmsce.ac.in","factual_id":"0c8c762c-52df-48d0-9add-1e6ef3f4df0d","fax":"080 2661 4357","hours":{"monday":[["7:00","15:00"]],"tuesday":[["7:00","14:00"]],"wednesday":[["7:00","13:00"]],"thursday":[["7:00","13:00"]],"friday":[["6:00","14:00"]],"saturday":[["7:00","14:00"]],"sunday":[["10:00","13:00"]]},"hours_display":"Mon 7:00-15:00; Tue 7:00-14:00; Wed-Thu 7:00-13:00; Fri 6:00-14:00; Sat 7:00-14:00; Sun 10:00-13:00","latitude":12.94172,"locality":"Bangalore","longitude":77.565889,"name":"BMS College of Engineering","postcode":"560019","region":"Karnataka","tel":"080 2662 2130","website":"http://www.bmsce.ac.in"},{"address":"R V Vidyanikethan Post, Mysore Road","category_ids":[29],"category_labels":[["Community and Government","Education","Colleges and Universities"]],"country":"in","email":"principal@rvce.ac.in","factual_id":"0389cc9b-0368-4ad7-8259-0c6021cd18d0","fax":"080 2860 0337","latitude":12.923694,"locality":"Bangalore","longitude":77.499105,"name":"R V College Of Engineering","postcode":"560059","region":"Karnataka","tel":"080 2860 1700","website":"http://www.rvce.ac.in"},"included_rows":1,"total_row_count":2}}
我从以下代码中获取
WebRequest request = WebRequest.Create("RequestURL");
// If required by the server, set the credentials.
request.Credentials = CredentialCache.DefaultCredentials;
// Get the response.
WebResponse response = request.GetResponse();
// Display the status.
Console.WriteLine(((HttpWebResponse)response).StatusDescription);
// Get the stream containing content returned by the server.
Stream dataStream = response.GetResponseStream();
// Open the stream using a StreamReader for easy access.
StreamReader reader = new StreamReader(dataStream);
// Read the content.
string responseFromServer = reader.ReadToEnd();
用于:
dynamic json = JsonConvert.DeserializeObject(responseFromServer);
var data = json.response;
foreach (var album in data)
{
var address = album.address;
}
我无法反序列化响应。我想从上面的Json获取数据。任何帮助,将不胜感激。谢谢
答案 0 :(得分:2)
你的json.response不是Enumerable。 json.response中的属性数据是,你应该使用
var data = json.response.data as JArray