.Net解析JSON數據

using System;
using System.Web.Script.Serialization;
using System.Collections.Generic;
public partial class Demo : System.Web.UI.Page
{
    protected string JSON
    {
        get
        {
            return Request.QueryString["json"];
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        JavaScriptSerializer serializer = new JavaScriptSerializer();
        Dictionary<string, object> json = (Dictionary<string, object>)serializer.DeserializeObject(JSON);
        object value;
        if (json.TryGetValue("name", out value))
        {
            Response.Write(value.ToString());
        }
    }
}

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章