【发布时间】:2018-07-30 16:14:20
【问题描述】:
public class information
{
public string name { get; set; }
public string surname { get; set; }
}
public class JsonFormat
{
public IList<information> information { get; set; }
}
protected void gettextbox_Click(object sender, EventArgs e)
{
JsonFormat newjson = new JsonFormat();
List<information> p = new List<information>();
information add1 = new information { name = textbox1.Text , surname = textbox2.Text };
information add2 = new information { name = textbox3.Text, surname = textbox4.Text };
p.Add(add1);
p.Add(add2);
newjson.information = p;
string json = JsonConvert.SerializeObject(newjson);
}
这里是字符串:
"{\"information\":[{\"name\":\"data1\",\"surname\":\"data2\"}, \"name\":\"data3\",\"surname\":\"data4\"}]}"
这里没问题,但是如何反序列化列表中的数据? 提前感谢您的帮助。
【问题讨论】:
标签: c# asp.net json serialization json-deserialization