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

    }
    }
    }
    }

  • 相关阅读:
    Backbone学习记录(6)
    Backbone学习记录(5)
    Backbone学习记录(4)
    PHP中抽象类,接口定义
    php和js中json的编码和解码
    jquery中 dom对象与jQuery对象相互转换
    js post跳转
    javascript中的三种弹窗
    出现多个sessid
    php中cookie的操作
  • 原文地址:https://www.cnblogs.com/kexb/p/4633806.html
Copyright © 2011-2022 走看看