zoukankan      html  css  js  c++  java
  • EasyUI

    使用 一般处理程序(ashx)返回Json值。

    原始Json数组的格式:

    [
        {
            "number":"01",
            "name":"张三",
            "sex":""
        },
        {
            "number":"02",
            "name":"李四",
            "sex":""
        },
        {
            "number":"03",
            "name":"小明",
            "sex":""
        }
    ]

    //----------

    其中,双引号【""】在C#中不能直接拼接,而又不能使用单引号【'】,所以要加上转义字符【】。格式如下:

    //----------

    格式化之后Json:

            public void ProcessRequest(HttpContext context)
            {
                context.Response.ContentType = "application/json";
    
                StringBuilder strjson = new StringBuilder();
                strjson.Append("[");
                strjson.Append("{"number":"01","name":"张三","sex":"男"}");
                strjson.Append(",");
                strjson.Append("{"number":"02","name":"李四","sex":"男"}");
                strjson.Append(",");
                strjson.Append("{"number":"02","name":"王五","sex":"女"}");
                strjson.Append("]");
    
                context.Response.Write(strjson);
            }
  • 相关阅读:
    HDU 3068 Manacher
    HDU 6188最小费用流
    Codeforces Round #442 (Div. 2) Danil and a Part-time Job
    并查集
    HDU 5988最小网络流(浮点数)
    HOJ
    HOJ
    POJ
    POJ
    关于async
  • 原文地址:https://www.cnblogs.com/KTblog/p/4910973.html
Copyright © 2011-2022 走看看