请问大家c# asp.net 如何在后台对json数据解码

时间:2023-01-02 10:04:19
请问大家我在后台.cs文件中如何能将返回的已经编码的json数据解码呢?就是不用前台的js,只在后台解码,请问高手们可以做到这一点吗?具体代码能附上来吗?谢谢大哥大姐了!!!

6 个解决方案

#1


关注下,看看有没人能从后台获取json字符串。

#2


估计可以吧,看下第三方的东西就好了.
C井与JSON相互转换.

#3


private string getRenderCode(string str_Select_BDZ_Value)
    {
        DBOperator.DBShell dbShell = new DBOperator.DBShell();//引用 数据库操作的dll文件
        if (dbShell == null)
            dbShell = new DBOperator.DBShell();

        string strCmd = "select * from SB_XL_H WHERE nparentid='" + str_Select_BDZ_Value + "'";
        DataTable dt_hmc = dbShell.OleDbDtExecuteSelectCmd(strCmd);//环名称 数据表
        dt_hmc.TableName = "环名称";

        //现在开始编码
        // Creates and initializes the source Hashtable.
        Hashtable mySourceHT = new Hashtable();
        for (int i = 0; i < dt_hmc.Rows.Count;i++)
        {
            mySourceHT.Add(dt_hmc.Rows[i]["XL_H_MC"], dt_hmc.Rows[i]["XL_H_BH"]);
        }
        
        string strEnCode = JSON.JsonEncode((object)mySourceHT);//编码成字符串成功了,然后就能通过ICALLBACK来进行异步发送了。
        return strEnCode;//将编码成JSON的字符串返回

    }


JSON编码解码

#4


3楼的师傅您好 请问下代码中的JSON.JsonEncode 
这个json对象是类库还是类 我看了底下的文章 找不到json这个类啊 您能给附上一个吗 谢谢 

#5


从官网上下载JSON.cs 我死活找不到 那个好心的大哥大姐帮忙附上来一个呢 或者告诉在那有

#6


顶顶顶继续问啦!谢谢大家来看看啦

#1


关注下,看看有没人能从后台获取json字符串。

#2


估计可以吧,看下第三方的东西就好了.
C井与JSON相互转换.

#3


private string getRenderCode(string str_Select_BDZ_Value)
    {
        DBOperator.DBShell dbShell = new DBOperator.DBShell();//引用 数据库操作的dll文件
        if (dbShell == null)
            dbShell = new DBOperator.DBShell();

        string strCmd = "select * from SB_XL_H WHERE nparentid='" + str_Select_BDZ_Value + "'";
        DataTable dt_hmc = dbShell.OleDbDtExecuteSelectCmd(strCmd);//环名称 数据表
        dt_hmc.TableName = "环名称";

        //现在开始编码
        // Creates and initializes the source Hashtable.
        Hashtable mySourceHT = new Hashtable();
        for (int i = 0; i < dt_hmc.Rows.Count;i++)
        {
            mySourceHT.Add(dt_hmc.Rows[i]["XL_H_MC"], dt_hmc.Rows[i]["XL_H_BH"]);
        }
        
        string strEnCode = JSON.JsonEncode((object)mySourceHT);//编码成字符串成功了,然后就能通过ICALLBACK来进行异步发送了。
        return strEnCode;//将编码成JSON的字符串返回

    }


JSON编码解码

#4


3楼的师傅您好 请问下代码中的JSON.JsonEncode 
这个json对象是类库还是类 我看了底下的文章 找不到json这个类啊 您能给附上一个吗 谢谢 

#5


从官网上下载JSON.cs 我死活找不到 那个好心的大哥大姐帮忙附上来一个呢 或者告诉在那有

#6


顶顶顶继续问啦!谢谢大家来看看啦