我们应该使用哪个程序集或命名空间来包含Json对象,Json数组或任何任何与Json相关的操作。 [英] Which assembly or namespace should we use to include a Json object,Json array or any any Json related operations.

查看:60
本文介绍了我们应该使用哪个程序集或命名空间来包含Json对象,Json数组或任何任何与Json相关的操作。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.IO;
using System.Text;
//using Oracle.DataAccess.Client;
using Timex.EmployeeLifeCycle;
using System.Data;
using System.Data.OracleClient;
using System.Configuration;
using Timex.Shared;
using Timex.Project;

public partial class PM_Roots_RootChild : System.Web.UI.Page
{
    clsFunction fun = new clsFunction();
    App_Common objMessage = new App_Common();
    Common objBl = new Common();
    RootChild rs = new RootChild();
    string emp_mid;

     
    protected void Page_Load(object sender, EventArgs e)
    
    {
        emp_mid= txtEmpmid.Text;
        
        GenerateFlowChart();

        //UCpeople.txtSearchChange += new EventHandler(UCpeople_txtSearchChange);

        if (!Page.IsPostBack)
        {
            
        }
        //txtEmpmid.Attributes.Add("onblur", "javascript:init('" + txtEmpmid.ClientID + "', '" + txtEmpname.ClientID + "')");
        //txtEmpmid.Attributes.Add("onblur", "javascript:initTest('" + txtEmpmid.ClientID + "','" + txtEmpname.ClientID + "')");
        txtEmpmid.Attributes.Add("onblur", "javascript:initTest('" + txtEmpmid.ClientID + "','" + hdnJsonData.ClientID + "')");
        btnShowGraph.Attributes.Add("onClick", "javascript:ReloadFrame('" + frmCtrl.ClientID + "','" + hdnJsonData.ClientID + "')");

        //frmCtrl.s
       
    }

    //void UCpeople_txtSearchChange(object sender, EventArgs e)
    //{
    //    if (!UCpeople.Text.Equals(""))
    //    {
    //        DataSet ds = new DataSet();
    //        ds = rs.Select_emp(emp_mid);
    //        UCpeople.Text = UCpeople.Value;
    //        if (ds.Tables.Count != 0)
    //        {
    //            txtEmpmid.Text = ds.Tables[0].Rows[0]["EMP_NAME"].ToString().Replace(" ", "");
    //        }
    //    }
    //}


    
    private void GenerateFlowChart()
    {
        try
        {
            Timex.Project.RootChild rc = new Timex.Project.RootChild();
            rc.GenarateFlow(UCpeople.Value, ddpLevel.SelectedValue);
            DataTable dt = new DataTable();
            dt = fun.GetDataTable("SELECT * FROM TEMP_FLOW_REPORT ORDER BY FLOW_LEVEL, emp_mid");
            StringBuilder sb = new StringBuilder();
            sb.Append (Write_Header()).AppendLine();
            sb.Append("function init(){").AppendLine();
            sb.Append("    //init data").AppendLine();
            sb.Append("    var json = {").AppendLine();
            //sb.Append("        id: " + (char)34 + UCpeople.Code + (char)34 + ",").AppendLine();
            sb.Append("        id: " + (char)34 + "EM000751" + (char)34 + ",").AppendLine();
            sb.Append("        name: " + (char)34 + UCpeople.Text + (char)34 + ",").AppendLine();
            sb.Append("        data: {},").AppendLine();
            sb.Append(Write_Parent(dt, UCpeople.Value)).AppendLine();
            sb.Append("};").AppendLine();
            sb.Append(Write_Footer()).AppendLine();
            sb.Append("}").AppendLine();
            //System.IO.File.WriteAllText(@"D:\OSOURCE-ONEX\Application Source Code\trunk\Code\PM\Roots\js\example_new.js", sb.ToString());

        }
        catch (Exception ex)
        {
            throw ex; 
        }
    }
}





-Edit-

添加代码块

推荐答案

.NET的流行高性能JSON框架:NewtonSoft.JSON.dll



http://james.newtonking.com/json [ ^ ]
Popular high-performance JSON framework for .NET : NewtonSoft.JSON.dll

http://james.newtonking.com/json[^]


一种方法是使用(可用的) .NET 3.5)System.Runtime.Serialization.Json命名空间中的DataContractJsonSerializer:[ ^ ]。



我不熟悉System.Web。帮助设施,但是,我怀疑该库中的Json类可能有用:[ ^ ]。



Mehdi Gholam,在CodeProject上,有非常快的JSON和BinaryJSON序列化/反序列化的优秀代码: [ ^ ],[ ^ ]。这些项目始于2011年,Mehdi一直非常慷慨地支持他们,并经常更新,添加新功能和提高性能。
One way to go would be to use the (available as of .NET 3.5) DataContractJsonSerializer in the System.Runtime.Serialization.Json Namespace: [^].

I am not familiar with the System.Web.Helpers facilities, but, I suspect that the Json Class in that library might be useful: [^].

Mehdi Gholam, here on CodeProject, has excellent code for very fast JSON and BinaryJSON serialize/deserialize: [^], [^]. These projects were started in 2011, and Mehdi has been supporting them very generously all along, and updating them, adding new features, and improving performance, frequently.


这篇关于我们应该使用哪个程序集或命名空间来包含Json对象,Json数组或任何任何与Json相关的操作。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆