У меня есть поток данных от я хочу, чтобы получить "estimatedResultCount":"399"
от этого ниже данныхкак извлекать данные JSon
как получить 399 значение из этого подхода Разбор JSON -> responseData -> курсор -> estimatedResultCount вы получите счет поддержки.
{
"responseData": {
"results": [
{
"GsearchResultClass": "GwebSearch",
"unescapedUrl": "http://www.homeocare.in/",
"url": "http://www.homeocare.in/",
"visibleUrl": "www.homeocare.in",
"cacheUrl": "http://www.google.com/search?q=cache:E7xF9dtFWgIJ:www.homeocare.in",
"title": "Homeopathy Clinics in Hyderabad - Homeopathy Treatment",
"titleNoFormatting": "Homeopathy Clinics in Hyderabad - Homeopathy Treatment",
"content": "Homeocare International - World Class Homeopathy Clinic in India provides \ninformation on causes, symptoms, and Homeopathy treatment of various \ndiseases."
},
{
"GsearchResultClass": "GwebSearch",
"unescapedUrl": "http://www.homeocare.in/contactus.html",
"url": "http://www.homeocare.in/contactus.html",
"visibleUrl": "www.homeocare.in",
"cacheUrl": "http://www.google.com/search?q=cache:zrjNDKonZY0J:www.homeocare.in",
"title": "Homeocare International | Contact Us",
"titleNoFormatting": "Homeocare International | Contact Us",
"content": "To get best Homeopathy treatment Contact Homeocare International through \nphone or fill contact form. We have branches all over South India."
},
{
"GsearchResultClass": "GwebSearch",
"unescapedUrl": "http://www.homeocare.in/testimonials.html",
"url": "http://www.homeocare.in/testimonials.html",
"visibleUrl": "www.homeocare.in",
"cacheUrl": "http://www.google.com/search?q=cache:oPJKzW6sHOkJ:www.homeocare.in",
"title": "Homeocare International Reviews/Testimonials",
"titleNoFormatting": "Homeocare International Reviews/Testimonials",
"content": "Homeocare International Reviews/Testimonials for Happy Patient. We pride \nourselves on excellent service, and our reviews show it!"
},
{
"GsearchResultClass": "GwebSearch",
"unescapedUrl": "http://www.homeocare.in/arthritis.html",
"url": "http://www.homeocare.in/arthritis.html",
"visibleUrl": "www.homeocare.in",
"cacheUrl": "http://www.google.com/search?q=cache:gqHnM_Tg0hcJ:www.homeocare.in",
"title": "Homeopathy Treatment for Arthritis | Arthritis Treatment",
"titleNoFormatting": "Homeopathy Treatment for Arthritis | Arthritis Treatment",
"content": "Get Homeopathy Treatment for arthritis and rheumatoid arthritis at Homeocare \nInternational provides safe and effective remedies with no side effects."
}
],
"cursor": {
"resultCount": "399",
"pages": [
{
"start": "0",
"label": 1
},
{
"start": "4",
"label": 2
},
{
"start": "8",
"label": 3
},
{
"start": "12",
"label": 4
},
{
"start": "16",
"label": 5
},
{
"start": "20",
"label": 6
},
{
"start": "24",
"label": 7
},
{
"start": "28",
"label": 8
}
],
"estimatedResultCount": "399",
"currentPageIndex": 0,
"moreResultsUrl": "http://www.google.com/search?oe=utf8&ie=utf8&source=uds&start=0&hl=en&q=site:homeocare.in",
"searchResultTime": "0.09"
}
},
"responseDetails": null,
"responseStatus": 200
}
Код
string strurl = "http://ajax.googleapis.com/ajax/services/search/web?v=1.0&q=site:homeocare.in";
StreamReader stream = objm.URLServerRequest(strurl);
string myResponse = stream.ReadToEnd();
public StreamReader URLServerRequest(string url)
{
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
StreamReader stream = new StreamReader(request.GetResponse().GetResponseStream());
return stream;
}
может я применять его в веб-приложения, я просто нужна строка estimatedResultCount общественности {получить; задавать; } @Paolo Coasta –
Несомненно, просто извлеките код в функции, и вы можете вызвать его из любого места, где бы вы ни хотели –
@PaoloCosta, вы использовали http://json2csharp.com/ для создания структуры класса? Если да, включите его в свой ответ, пожалуйста, чтобы будущие читатели знали, как их легко сгенерировать :) –