更新时间:2023-02-17 09:12:31
为什么不将字符串反序列化为字典,然后遍历显示部分的键?
why not deserialize the string into a dictionary, and then iterate through it's keys for the display part?
private string GetKeyValuePairs(string jsonString)
{
var resDict = JsonConvert.DeserializeObject<Dictionary<string, object>>(jsonString);
string sdict = string.Empty;
foreach (string key in resDict.Keys)
{
sdict += "<br/> " + key + " : " + (resDict[key].GetType() == typeof(JObject) ? GetKeyValuePairs(resDict[key].ToString()) : resDict[key].ToString());
}
return sdict;
}