मुझे जेसन युक्त एक स्ट्रिंग मिली है। यह इस तरह दिखता है:जेसन स्ट्रिंग से डेटा निकालें
"status_code":200,
"status_txt":"OK",
"data":
{
"img_name":"D9Y3z.png",
"img_url":"http:\/\/s1.uploads.im\/D9Y3z.png",
"img_view":"http:\/\/uploads.im\/D9Y3z.png",
"img_width":"167",
"img_height":"288",
"img_attr":"width=\"167\" height=\"288\"",
"img_size":"36.1 KB",
"img_bytes":36981,
"thumb_url":"http:\/\/s1.uploads.im\/t\/D9Y3z.png",
"thumb_width":360,
"thumb_height":360,
"source":"http:\/\/www.google.com\/images\/srpr\/nav_logo66.png",
"resized":"0",
"delete_key":"df149b075ab68c38"
}
मैं "img_url" पर भी नियंत्रण प्राप्त करने के लिए कोशिश कर रहा हूँ। मैं Json.NET स्थापित किया है और मैं इस तरह उदाहरण कुछ के लिए यहां इसी तरह के सवाल पाया ..
:
JObject o = JObject.Parse("{'People':[{'Name':'Jeff'},{'Name':'Joe'}]}");
// get name token of first person and convert to a string
string name = (string)o.SelectToken("People[0].Name");
मेरे मामले मैं ("img_url")
को ("People[0].Name")
बदल में, ("img_url[0])
etc..no भाग्य
यह अब मेरी कोड है:
public string tempJson { get; set; }
public ActionResult SaveUploadedFile(string test)
{
using (WebResponse wrs = wrq.GetResponse())
using (Stream stream = wrs.GetResponseStream())
using (StreamReader reader = new StreamReader(stream))
{
string json = reader.ReadToEnd();
tempJson = json;
}
}
मैं तार के साथ कुछ करने के लिए इससे पहले कि मैं मान प्राप्त कर सकते हैं है? धन्यवाद!
देखो बारीकी से। "Img_url" प्रॉपर्टी एक JSON ऑब्जेक्ट का हिस्सा है, जिसे फिर से JSON प्रॉपर्टी को असाइन किया जाता है। उस संपत्ति का नाम क्या है? – elgonzo
आपका मतलब डेटा है? मैं हार गया हूं? – user2915962
हां, "डेटा"। इसलिए आपको 'SelectToken ("data.img_url") का उपयोग करना चाहिए; ' – elgonzo