C# winform 解析JSON

1、引用Newtonsoft.Json;

using Newtonsoft.Json

 

2、解析

public class RootObject
{
public string reason { get; set; }
public result result { get; set; }
public string name { get; set; }
}
public class result
{
public string name { get; set; }
public string taxNumber { get; set; }
}

 

private void skinButton4_Click(object sender, EventArgs e)
{
string cname = skinTextBox1.Text.ToString();
WindowsPMSLites.WebServiceGetKs.GetKsService ks = new WindowsPMSLites.WebServiceGetKs.GetKsService();
string ksinfo = ks.getks("{\"name\":\"" + cname + "\",\"from\":\"QWFFFFFERER\"}");
//string ksinfo = skinTextBox2.Text;
skinTextBox2.Text = ConvertStringToJson(ksinfo);
RootObject rb = JsonConvert.DeserializeObject<RootObject>(ksinfo);
MessageBox.Show(rb.result.name);
MessageBox.Show(rb.result.taxNumber);

}

 

posted @ 2020-05-29 14:56  天空之上、只有蓝黑  阅读(1365)  评论(0编辑  收藏  举报