可以将一些配置信息已json格式存在数据库中读取的时候序列化。

  public partial class json序列化 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            StringBuilder builder = new StringBuilder();

            builder.Append("{");
            builder.Append("    \"CommonConfig\": {");
            builder.Append("        \"ChannelDepartmentCode\": \"9904\"");
            builder.Append("    }");
            builder.Append("}");

            JavaScriptSerializer jsonSerializer = new JavaScriptSerializer();

            PageConfig t = jsonSerializer.Deserialize<PageConfig>(builder.ToString());


        }


    }

    public class PageConfig
    {
        public CommonConfig CommonConfig { get; set; }

    }


    public class CommonConfig
    {
        public string ChannelDepartmentCode { get; set; }
    }

posted @ 2014-04-28 10:21  awp110  阅读(175)  评论(0编辑  收藏  举报