मेरे ऐप्स में से एक में, मुझे वेबरेक्वेस्ट से प्रतिक्रिया मिल रही है। सेवा शोकहारा सेवा है और एक परिणाम के नीचे JSON प्रारूप के लिए इसी तरह वापस आ जाएगी:HttpwebResponse json प्रतिक्रिया पढ़ना, सी #
byte[] bytes = Encoding.GetEncoding(contentEncoding).GetBytes(contents.ToString());
request.ContentLength = bytes.Length;
using (var requestStream = request.GetRequestStream()) {
requestStream.Write(bytes, 0, bytes.Length);
using (var twitpicResponse = (HttpWebResponse)request.GetResponse()) {
using (var reader = new StreamReader(twitpicResponse.GetResponseStream())) {
//What should I do here?
}
}
}
मैं प्रतिक्रिया कैसे पढ़ सकते हैं:
{
"id" : "1lad07",
"text" : "test",
"url" : "http:\/\/twitpic.com\/1lacuz",
"width" : 220,
"height" : 84,
"size" : 8722,
"type" : "png",
"timestamp" : "Wed, 05 May 2010 16:11:48 +0000",
"user" : {
"id" : 12345,
"screen_name" : "twitpicuser"
}
}
और यहाँ मेरे वर्तमान कोड है? मुझे यूआरएल और उपयोगकर्ता नाम चाहिए।
Restsharp को अपनी बाकी सेवा कॉल करने के लिए जांचना एक अच्छा विचार हो सकता है https://github.com/johnsheehan/RestSharp/wiki/Getting-Started आपके जीवन को 100000x ट्रैक के नीचे आसान बना देगा, और आप सेटअप कर सकते हैं इसके लिए डीकोड करने के लिए ऑब्जेक्ट मॉडल। – anthonyvscode