C#JSON解析得到键值

时间:2022-10-26 13:35:33

I am using Network JSON Plugin. I wanted to get JSON key. How I can get key?

我正在使用Network JSON插件。我想获得JSON密钥。我怎么能得到钥匙?

My JSON Code is :

我的JSON代码是:

"kat1":{
"gg_id":"aaa",
"ozellik":{
"Tarih Aralığı":{"Combo":""
},
"Durum":{
"Combo":"Sıfır"
}

My C# Code is :

我的C#代码是:

dynamic ozellik = veri.entegrekat; // My Parsed code is working

foreach (var kat in ozellik) // How  i get key
{
    MessageBox.Show("" + kat);    
}

When I am using KeyValuePair<string,string> or <Object,Object> I got error.

当我使用KeyValuePair 时出现错误。 ,object> ,string>

How I can retrieve value of key kat1 from JSON?

如何从JSON中检索密钥kat1的值?

1 个解决方案

#1


1  

I Fixed

Code :

var ozellik = veri.entegrekat;
                    Dictionary<string, dynamic> result = ozellik.ToObject<Dictionary<string, dynamic>>();

                    foreach (KeyValuePair<string, dynamic> kat in result)
                    {

                        MessageBox.Show(""+kat.Key);

                    }

#1


1  

I Fixed

Code :

var ozellik = veri.entegrekat;
                    Dictionary<string, dynamic> result = ozellik.ToObject<Dictionary<string, dynamic>>();

                    foreach (KeyValuePair<string, dynamic> kat in result)
                    {

                        MessageBox.Show(""+kat.Key);

                    }