在winform中解析Json字符串,只需要引用dll,即可解析json成相应的对象,非常方便。
public void GetJson(string sNu)
{
string sUrl = "******";
WebClient client = new WebClient();
client.Credentials = CredentialCache.DefaultCredentials;
Byte[] data = client.DownloadData(sUrl);
string str = Encoding.UTF8.GetString(data);
MyClass obj= JsonConvert.DeserializeObject(str);
this.message = obj.message;
this.nu = obj.nu;
this.ischeck = obj.ischeck;
this.com = obj.com;
this.updatetime = obj.updatetime;
this.status = obj.status;
this.condition = obj.condition;
this.state = obj.state;
this.data = obj.data;
}
1