To tidy up the code, this is the second way to read the JSON and then deserialize it into an object with the following code:
1 Public StaticOrder GetOrderInfo (string_tid,string_orderno)2 {3 Try4 {5StringBuilder serviceurl =NewStringBuilder (); 6Serviceurl.append ("Http://10.10.10.10/queryOrderTwo?");7Serviceurl.appendformat ("tid={0}&tname=&email=&employeeno=&corpcode=&servicecode=&pagenum=&pagesize= &producttype=&datefrom=&dateto=&datetype=&sono={1}", _tid, _orderno);8 string_result =Excuteget (serviceurl.tostring ());9 returnJsonconvert.deserializeobject<order>(_result);Ten } One Catch(Exception e) A { -Addlog (_tid,"Get order List exception:"+ E.message.tosql (),"getorderlist"); - return NULL; the } -}
The Excuteget method is different from the first,
1 Public Static string Excuteget (string URL)2{3 var request = ( HttpWebRequest) webrequest.create (URL); 4 var response = (HttpWebResponse) request. GetResponse (); 5 return New StreamReader (response. GetResponseStream ()). ReadToEnd (); 6 }
. NET gets JSON from the network interface address, then resolves to object (ii)