C# Newtonsoft_JSON 如何循环取出KEY和VALUE

2025-02-26 06:18:54
推荐回答(2个)
回答1:

SortedDictionary keyList = new SortedDictionary();
foreach (JProperty jToken in JObject.Parse(paramStr).Properties())
                    {
                        keyList.Add(jToken.Name.ToString(), jToken.Value.ToString());
                    }

回答2:

SortedList STK = new SortedList();
STK.Add("1", "2");
STK.Add("3", "4");
foreach (KeyValuePair item in STK)
{
Console.Write(string.Format("{0}:{1}",item.Key,item.Value));
}