• c# 数据源转Json格式_应用到IPHONE数据服务后台


    连接地址:http://www.cnblogs.com/xinjian/archive/2010/11/23/1885225.html

    新建一个一般处理程序,命名为JsonTransHander.ashx。内容如下:

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.Services;
    using System.Web.Script.Serialization;

    namespace auotoCompleteText
    {
    /// <summary>
    /// $codebehindclassname$ 的摘要说明
    /// </summary>
    [WebService(Namespace = "http://tempuri.org/")]
    [WebServiceBinding(ConformsTo
    = WsiProfiles.BasicProfile1_1)]
    public class JsonTransHander : IHttpHandler
    {
    public void ProcessRequest(HttpContext context)
    {
    context.Response.ContentType
    = "text/plain";
    //初始化数据
    List<People> peopleList = new List<People>();
    for (int i = 0; i < 10; i++)
    {
    People people
    = new People() { ID=i,Name="name"+i};
    peopleList.Add(people);
    }


    //引用System.Web.Extensions .net3.5框架
    JavaScriptSerializer serializer=new JavaScriptSerializer();
    //转换
    var jsonData= serializer.Serialize(peopleList);

    //返回
    context.Response.Write(jsonData);
    }
    public bool IsReusable
    {
    get
    {
    return false;
    }
    }
    }

    public class People
    {
    public string Name
    {
    set;
    get;
    }
    public int ID
    {
    set;
    get;
    }
    }
    }
  • 相关阅读:
    SCRUM第一天
    第八周总结
    第7周总结
    团队项目nabcd
    人月神话1
    课堂练习之四则运算
    第六周总结
    Storm Grouping —— 流分组策略
    抓取网页内容生成Kindle电子书(转)
    浅析PageRank算法(转)
  • 原文地址:https://www.cnblogs.com/xingchen/p/2139535.html
Copyright © 2020-2023  润新知