• <small id='fkfgJ'></small><noframes id='fkfgJ'>

  • <legend id='fkfgJ'><style id='fkfgJ'><dir id='fkfgJ'><q id='fkfgJ'></q></dir></style></legend>
  • <tfoot id='fkfgJ'></tfoot>

        <bdo id='fkfgJ'></bdo><ul id='fkfgJ'></ul>

        <i id='fkfgJ'><tr id='fkfgJ'><dt id='fkfgJ'><q id='fkfgJ'><span id='fkfgJ'><b id='fkfgJ'><form id='fkfgJ'><ins id='fkfgJ'></ins><ul id='fkfgJ'></ul><sub id='fkfgJ'></sub></form><legend id='fkfgJ'></legend><bdo id='fkfgJ'><pre id='fkfgJ'><center id='fkfgJ'></center></pre></bdo></b><th id='fkfgJ'></th></span></q></dt></tr></i><div id='fkfgJ'><tfoot id='fkfgJ'></tfoot><dl id='fkfgJ'><fieldset id='fkfgJ'></fieldset></dl></div>

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

        Finding a node (JObject) within JArray using JSON.NET library(使用 JSON.NET 库在 JArray 中查找节点 (JObject))

        <tfoot id='TpFWs'></tfoot>
          <tbody id='TpFWs'></tbody>
          <bdo id='TpFWs'></bdo><ul id='TpFWs'></ul>
          <i id='TpFWs'><tr id='TpFWs'><dt id='TpFWs'><q id='TpFWs'><span id='TpFWs'><b id='TpFWs'><form id='TpFWs'><ins id='TpFWs'></ins><ul id='TpFWs'></ul><sub id='TpFWs'></sub></form><legend id='TpFWs'></legend><bdo id='TpFWs'><pre id='TpFWs'><center id='TpFWs'></center></pre></bdo></b><th id='TpFWs'></th></span></q></dt></tr></i><div id='TpFWs'><tfoot id='TpFWs'></tfoot><dl id='TpFWs'><fieldset id='TpFWs'></fieldset></dl></div>

              <legend id='TpFWs'><style id='TpFWs'><dir id='TpFWs'><q id='TpFWs'></q></dir></style></legend>

                <small id='TpFWs'></small><noframes id='TpFWs'>

                  本文介绍了使用 JSON.NET 库在 JArray 中查找节点 (JObject)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  限时送ChatGPT账号..

                  我正在使用 JSON.NET 库.我创建了几个 JObject 并将它们添加到 JArray.

                  I am using JSON.NET library. I have created few JObjects and added them to a JArray.

                  JArray array = new JArray();
                  
                  JObject obj = new JObject();
                  obj.Add(new JProperty("text", "One"));
                  obj.Add(new JProperty("leaf", false));
                  array.Add(obj);
                  
                  obj = new JObject();
                  obj.Add(new JProperty("text", "Two"));
                  obj.Add(new JProperty("leaf", false));
                  array.Add(obj);
                  
                  obj = new JObject();
                  obj.Add(new JProperty("text", "Three"));
                  obj.Add(new JProperty("leaf", true));
                  array.Add(obj);
                  

                  现在我想找到一个文本(JProperty)是Two的JObject.如何使用 JProperty 在 JArray 中找到 JObject.

                  Now I want to find a JObject who's text (JProperty) is Two. How can I find a JObject within a JArray by using a JProperty.

                  推荐答案

                  你可以这样找到:

                  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.

                  这篇关于使用 JSON.NET 库在 JArray 中查找节点 (JObject)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  Force JsonConvert.SerializeXmlNode to serialize node value as an Integer or a Boolean(强制 JsonConvert.SerializeXmlNode 将节点值序列化为整数或布尔值)
                  Using JSON to Serialize/Deserialize TimeSpan(使用 JSON 序列化/反序列化 TimeSpan)
                  Could not determine JSON object type for type quot;Classquot;(无法确定类型“Class的 JSON 对象类型.)
                  How to deserialize a JSONP response (preferably with JsonTextReader and not a string)?(如何反序列化 JSONP 响应(最好使用 JsonTextReader 而不是字符串)?)
                  how to de-serialize JSON data in which Timestamp it-self contains fields?(如何反序列化时间戳本身包含字段的JSON数据?)
                  JSON.Net custom contract serialization and Collections(JSON.Net 自定义合约序列化和集合)
                    <bdo id='4MnL9'></bdo><ul id='4MnL9'></ul>

                      <small id='4MnL9'></small><noframes id='4MnL9'>

                      <tfoot id='4MnL9'></tfoot>
                      <i id='4MnL9'><tr id='4MnL9'><dt id='4MnL9'><q id='4MnL9'><span id='4MnL9'><b id='4MnL9'><form id='4MnL9'><ins id='4MnL9'></ins><ul id='4MnL9'></ul><sub id='4MnL9'></sub></form><legend id='4MnL9'></legend><bdo id='4MnL9'><pre id='4MnL9'><center id='4MnL9'></center></pre></bdo></b><th id='4MnL9'></th></span></q></dt></tr></i><div id='4MnL9'><tfoot id='4MnL9'></tfoot><dl id='4MnL9'><fieldset id='4MnL9'></fieldset></dl></div>
                      1. <legend id='4MnL9'><style id='4MnL9'><dir id='4MnL9'><q id='4MnL9'></q></dir></style></legend>

                          <tbody id='4MnL9'></tbody>