久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

<i id='Mhco9'><tr id='Mhco9'><dt id='Mhco9'><q id='Mhco9'><span id='Mhco9'><b id='Mhco9'><form id='Mhco9'><ins id='Mhco9'></ins><ul id='Mhco9'></ul><sub id='Mhco9'></sub></form><legend id='Mhco9'></legend><bdo id='Mhco9'><pre id='Mhco9'><center id='Mhco9'></center></pre></bdo></b><th id='Mhco9'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='Mhco9'><tfoot id='Mhco9'></tfoot><dl id='Mhco9'><fieldset id='Mhco9'></fieldset></dl></div>
<legend id='Mhco9'><style id='Mhco9'><dir id='Mhco9'><q id='Mhco9'></q></dir></style></legend><tfoot id='Mhco9'></tfoot>

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

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

        在 C# 中搜索 JSON.net 對象內的嵌套值

        Search for a nested value inside of a JSON.net object in C#(在 C# 中搜索 JSON.net 對象內的嵌套值)
          <tbody id='xrBfp'></tbody>
        <legend id='xrBfp'><style id='xrBfp'><dir id='xrBfp'><q id='xrBfp'></q></dir></style></legend>
          <bdo id='xrBfp'></bdo><ul id='xrBfp'></ul>
          <tfoot id='xrBfp'></tfoot>

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

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

                  本文介紹了在 C# 中搜索 JSON.net 對象內的嵌套值的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  我有一個從服務器返回的 JSON 流,我需要使用 JSON.net 搜索節點ID"的特定值來解析數據.而且我幾乎可以讓它工作,但不完全是因為返回的結果彼此嵌套得很深——這是因為我得到了一個文件夾結構.我已經將 JSON 簡化為一個更簡單的版本.我得到了這個:

                  I've got a JSON stream coming back from a server, and I need to search for a specific value of the node "ID" using JSON.net to parse the data. And I can almost make it work, but not quite because the results coming back are deeply nested in each other -- this is due to the fact that I'm getting a folder structure back. I've boiled the JSON down to a much simpler version. I'm getting this:

                  {
                      "data": {
                          "id": 0,
                          "name": "",
                          "childFolders": [{
                              "id": 19002,
                              "name": "Locker",
                              "childFolders": [{
                                  "id": 19003,
                                  "name": "Folder1",
                                  "childFolders": [],
                                  "childComponents": [{
                                      "id": 19005,
                                      "name": "route1",
                                      "state": "STOPPED",
                                      "type": "ROUTE"
                                  }]
                              }, {
                                  "id": 19004,
                                  "name": "Folder2",
                                  "childFolders": [],
                                  "childComponents": [{
                                      "id": 19008,
                                      "name": "comm1",
                                      "state": "STOPPED",
                                      "type": "COMMUNICATION_POINT"
                                  }, {
                                      "id": 19006,
                                      "name": "route2",
                                      "state": "STOPPED",
                                      "type": "ROUTE"
                                  }, {
                                      "id": 19007,
                                      "name": "route3",
                                      "state": "STOPPED",
                                      "type": "ROUTE"
                                  }]
                              }],
                              "childComponents": []
                          }],
                          "childComponents": []
                      },
                      "error": null
                  }
                  

                  我幾乎可以走到那里:

                  var objects = JObject.Parse(results);
                  var subobjects = objects["data"]["childFolders"][0]["childFolders"][1];
                  

                  我可以在調試視圖中看到它會解析對象,但不會讓我在其中進行搜索.

                  I can see in the debug view that it'll parse the object, but won't let me search within.

                  我的最終目標是能夠搜索route3"并返回 19007,因為那是該路線的 ID.我找到了一些結果,但所有結果都假設您知道對象的嵌套程度.我正在搜索的對象可能是 2 深或 20 深.

                  My ultimate goal is to be able to search for "route3" and get back 19007, since that's the ID for that route. I've found some results, but all of them assume you know how far nested the object is. The object I'm searching for could be 2 deep or 20 deep.

                  推薦答案

                  我的最終目標是能夠搜索到route3"并回到19007

                  My ultimate goal is to be able to search for "route3" and get back 19007

                  您可以使用 JObject 的 linqDescendants 方法來做到這一點:

                  You can use linq and Descendants method of JObject to do it:

                  var dirs = JObject.Parse(json)
                              .Descendants()
                              .Where(x=>x is JObject)
                              .Where(x=>x["id"]!=null && x["name"]!=null)
                              .Select(x =>new { ID= (int)x["id"], Name = (string)x["name"] })
                              .ToList();
                  
                  var id = dirs.Find(x => x.Name == "route3").ID;
                  

                  這篇關于在 C# 中搜索 JSON.net 對象內的嵌套值的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

                  【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

                  相關文檔推薦

                  Ignore whitespace while reading XML(讀取 XML 時忽略空格)
                  XML to LINQ with Checking Null Elements(帶有檢查空元素的 XML 到 LINQ)
                  Reading XML with unclosed tags in C#(在 C# 中讀取帶有未閉合標簽的 XML)
                  Parsing tables, cells with Html agility in C#(在 C# 中使用 Html 敏捷性解析表格、單元格)
                  delete element from xml using LINQ(使用 LINQ 從 xml 中刪除元素)
                  Parse malformed XML(解析格式錯誤的 XML)
                • <tfoot id='yKvQy'></tfoot>

                    • <bdo id='yKvQy'></bdo><ul id='yKvQy'></ul>

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

                        1. <legend id='yKvQy'><style id='yKvQy'><dir id='yKvQy'><q id='yKvQy'></q></dir></style></legend>

                            <i id='yKvQy'><tr id='yKvQy'><dt id='yKvQy'><q id='yKvQy'><span id='yKvQy'><b id='yKvQy'><form id='yKvQy'><ins id='yKvQy'></ins><ul id='yKvQy'></ul><sub id='yKvQy'></sub></form><legend id='yKvQy'></legend><bdo id='yKvQy'><pre id='yKvQy'><center id='yKvQy'></center></pre></bdo></b><th id='yKvQy'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='yKvQy'><tfoot id='yKvQy'></tfoot><dl id='yKvQy'><fieldset id='yKvQy'></fieldset></dl></div>
                              <tbody id='yKvQy'></tbody>
                            主站蜘蛛池模板: 99久久久无码国产精品 | 亚洲综合在线视频 | 欧美成人一区二区 | 女朋友的闺蜜3韩国三级 | 一区视频在线播放 | 在线男人天堂 | 一区二区三区播放 | 免费亚洲一区二区 | 欧美精品久久久久久久久久 | 中文在线亚洲 | 草久久 | 国产成人叼嘿视频在线观看 | 一区二区三区中文字幕 | 涩色视频在线观看 | 国产精品免费一区二区三区 | 国产成人精品免费 | v片网站| 在线观看中文字幕 | 日韩精品免费播放 | 国产精品欧美一区二区三区不卡 | 欧美日韩一区二区在线观看 | 国产在线二区 | 蜜桃视频在线观看免费视频网站www | 天天综合久久 | 在线观看视频你懂得 | 日韩在线免费观看视频 | 欧美激情综合 | 中文字幕在线免费观看 | 91久久国产综合久久91精品网站 | 国产成人精品a视频一区www | 久久综合99 | 欧美偷偷操 | 国产精品视频中文字幕 | 老牛嫩草一区二区三区av | 亚洲精品成人av | 中文字幕在线第二页 | 国内av在线 | 色婷婷亚洲国产女人的天堂 | 免费观看色 | 天天天操天天天干 | 国产成人综合一区二区三区 |