public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
string json = "{\"result\":\"0\",\"res_info\":\"ok\",\"queryorder_info\":\"info\"}";
JavaScriptSerializer js = new JavaScriptSerializer(); //实例化一个能够序列化数据的类
JsonClass list = js.Deserialize<JsonClass>(json); //将json数据转化为对象类型并赋值给list
string result = list.res_info;
Response.Write(result);
}
public struct JsonClass
{
public string result { get; set; } //属性的名字,必须与json格式字符串中的"key"值一样。
public string res_info { get; set; }
public string queryorder_info { get; set; }
}
}
时间: 2024-11-05 11:25:05