Json基础

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

namespace ajax
{
    /// 
    /// Json 的摘要说明
    /// 
    public class Json : IHttpHandler
    {

        public void ProcessRequest(HttpContext context)
        {
            
            context.Response.ContentType = "text/plain";
            JavaScriptSerializer jss = new JavaScriptSerializer();
           string json= jss.Serialize(new Person() {Age=20,Name="json"});
            context.Response.Write(json);
        }

        public bool IsReusable
        {
            get
            {
                return false;
            }
        }
    }
    public class Person 
    {
        public string Name { get; set; }
        public int Age { get; set; }
    }
}

  




    
    
    


    

  

 

  

转载于:https://www.cnblogs.com/blackHorseplan/p/3900818.html

你可能感兴趣的:(Json基础)