I am trying to parse a json file using json.net. The file looks like this
{X:
{
Title:"foo",
xxxx:xxxx
}
}
{Y:
{ZZ:
{Title: "bar",...}
}
}
I am trying to recurse down this structure processing all objects with a Title attribute. But I am confused about JToken
, JProperty
, JContainer
, JValue
, JObject
. Reading the source code has not left me much wiser and none of the samples help. I want something along the lines of
WalkNode(node, Action<Node> action)
{
foreach(var child in node.Children)
{
Action(child);
WalkNode(child);
}
}
Parse()
{
WalkNode(root, n=>
{
if(n["Title"] != null)
{
...
}
});
}
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…