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);
    }

    }
    }
    }
    }

  • 相关阅读:
    7
    6
    5
    3
    4
    2
    1
    寒假工作经历
    软件工程第三周的总结
    软件工程第三周的学习报告 html<input> final finally finalize 的比较 BigInteger
  • 原文地址:https://www.cnblogs.com/kexb/p/4633806.html
Copyright © 2011-2022 走看看