zoukankan      html  css  js  c++  java
  • 前台的json数组转化为List<T>集合

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Runtime.Serialization;
    using System.Runtime.Serialization.Json;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    namespace WebApplication13
    {

    //DataContract 和  DataMember不能缺少否则不能序列化成list<T>
    [DataContract]
    public class QuickFastPage
    {
    [DataMember]
    private int index { get; set; }
    [DataMember]
    private string url { get; set; }
    [DataMember]
    private string pageName { get; set; }
    }

    public partial class WebForm2 : System.Web.UI.Page
    {
    protected void Page_Load(object sender, EventArgs e)
    {
    if (!string.IsNullOrEmpty(Request["_method"]) && Request["_method"] == "setQuickFast")
    {
    string pagePostData = Request["postData"];
    if (!string.IsNullOrEmpty(pagePostData))
    {
    List<QuickFastPage> _Test = new List<QuickFastPage>();

    DataContractJsonSerializer _Json = new DataContractJsonSerializer(_Test.GetType());
    byte[] _Using = System.Text.Encoding.UTF8.GetBytes(pagePostData);
    System.IO.MemoryStream _MemoryStream = new System.IO.MemoryStream(_Using);
    _MemoryStream.Position = 0;

    _Test = (List<QuickFastPage>)_Json.ReadObject(_MemoryStream);
    }

    }
    }
    }
    }

  • 相关阅读:
    [GCJ2017R2]Fresh Chocolate
    李耀于NOIP2010集训出的题 Dvalue
    POI ZAW
    POI SZP
    無名(noname)
    幸运序列(lucky)
    [HNOI2001]求正整数
    灰狼呼唤着同胞(brethren)
    神在夏至祭降下了神谕(oracle)
    [bzoj 4237] 稻草人
  • 原文地址:https://www.cnblogs.com/kexb/p/4633806.html
Copyright © 2011-2022 走看看