且构网

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

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

更新时间:2023-01-18 08:36:03

您可以这样找到它:

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

这将在JArray中找到具有名为text且值为Two的属性的第一个JObject.如果不存在这样的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.