【发布时间】:2012-07-25 15:50:08
【问题描述】:
我有一个表示 JSON 的字符串,我想使用 JSON.NET 重命名一些属性。我需要一个用于任何 JSON 的通用函数。比如:
public static void Rename(JContainer container, Dictiontionary<string, string> mapping)
{
foreach (JToken el in container.Children())
{
JProperty p = el as JProperty;
if(el != null && mapping.ContainsKey(p.Name))
{
// **RENAME THIS NODE!!**
}
// recursively rename nodes
JContainer pcont = el as JContainer;
if(pcont != null)
{
Rename(pcont, mapping);
}
}
}
怎么做??
【问题讨论】:
标签: c# .net json json.net rename