One, the parsed JSON string is as follows
{"TinyURL": "Http:\/\/dwz.cn\/v9bxe", "status": 0, "Longurl": "http://mp.weixin.qq.com/s?__biz=MzAxODA3NTc1OQ==", " Err_msg ":"}
Second, before the operation of the download json.net
Third, add Reference Newtonsoft.json
Iv. Introduction of namespaces
Using Newtonsoft.json;
Using Newtonsoft.Json.Linq;
V. Post submission and JSON parsing
string postdatastr = Urltext;
String Url = "http://dwz.cn/create.php";
HttpWebRequest request = (HttpWebRequest) webrequest.create (URL);
Request. ContentType = "application/x-www-form-urlencoded";
Request. Cookiecontainer = new Cookiecontainer ();
Request. Method = "POST";
Request. ContentLength = Postdatastr.length;
Stream Myrequeststream = Request. GetRequestStream ();
StreamWriter mystreamwriter = new StreamWriter (Myrequeststream, encoding.getencoding ("gb2312"));
Mystreamwriter.write (POSTDATASTR);
Mystreamwriter.close ();
HttpWebResponse response = (HttpWebResponse) request. GetResponse ();
Stream Myresponsestream = Response. GetResponseStream ();
StreamReader Mystreamreader = new StreamReader (Myresponsestream, encoding.getencoding ("Utf-8"));
String retstring = Mystreamreader.readtoend ();
String Ujson = "[" + RetString + "]";
string Ujson = retstring;
Jarray ja = (jarray) jsonconvert.deserializeobject (Ujson);
Jobject o = (jobject) ja[0];
Jsonreader reader = new JsonTextReader (new StringReader (Ujson));
Jobject Jo = Jobject.parse (retstring);
This.textBox3.Text = o["TinyURL"]. ToString ();
This.textBox3.Text = Jo. Property ("TinyURL"). Value.tostring ();
C # Post submission and parsing JSON instances