欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

转换Json对象

程序员文章站 2024-03-18 18:20:16
...
js代码

var dataObj = eval("(" + WxData + ")");  // 转换为json对象
    /// <summary>
    /// 返回json
    /// </summary>
    /// <param name="code">代码</param>
    /// <param name="data">数据</param>
    /// <param name="msg">消息说明</param>
    private void resultJson(string code, string msg, object data)
    {
        Dictionary<string, object> result = new Dictionary<string, object>();
        result.Add("code", code);
        result.Add("data", data);
        result.Add("msg", msg);

        string resultJson = Newtonsoft.Json.JavaScriptConvert.SerializeObject(result);
        Response.Clear();
        Response.Write(resultJson);
        Response.End();

    }
Dictionary<string, object> dict = new Dictionary<string, object>();
                            dict.Add("token", token);
                            dict.Add("pageCount", pageCount);
                            dict.Add("data", wxArticleStr);

                            resultJson("200", "ok", dict);

 

相关标签: C#-ASPX-EF C#