且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

使用 JSON.NET 库在 JArray 中查找节点 (JObject)

更新时间:2023-01-18 08:48:47

你可以这样找到:

JObject jo = array.Children<JObject>()
    .FirstOrDefault(o => o["text"] != null && o["text"].ToString() == "Two");

这将在 JArray 中找到第一个 JObject,它的属性名为 text,其值为 Two.如果不存在这样的 JObject,则 jo 将为空.

This will find the first JObject in the JArray having a property named text with a value of Two. If no such JObject exists, then jo will be null.