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

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

    1. <small id='hVw5K'></small><noframes id='hVw5K'>

    2. <legend id='hVw5K'><style id='hVw5K'><dir id='hVw5K'><q id='hVw5K'></q></dir></style></legend>

          <bdo id='hVw5K'></bdo><ul id='hVw5K'></ul>
      1. 動態 JContainer (JSON.NET) &amp;在運行時迭代屬性

        dynamic JContainer (JSON.NET) amp; Iterate over properties at runtime(動態 JContainer (JSON.NET) amp;在運行時迭代屬性)

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

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

            <legend id='asYwl'><style id='asYwl'><dir id='asYwl'><q id='asYwl'></q></dir></style></legend>
                  <tbody id='asYwl'></tbody>
                  <bdo id='asYwl'></bdo><ul id='asYwl'></ul>
                  <tfoot id='asYwl'></tfoot>
                  本文介紹了動態 JContainer (JSON.NET) &amp;在運行時迭代屬性的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  我在 MVC4/.NET4 WebApi 控制器操作中收到一個 JSON 字符串.該操作的參數是 dynamic,因為我對接收端收到的 JSON 對象一無所知.

                  I'm receiving a JSON string in a MVC4/.NET4 WebApi controller action. The action's parameter is dynamic because I don't know anything on the receiving end about the JSON object I'm receiving.

                   public dynamic Post(dynamic myobject)        
                  

                  自動解析 JSON,生成的 dynamic 對象是 Newtonsoft.Json.Linq.JContainer.正如預期的那樣,我可以在運行時評估屬性,因此如果 JSON 包含類似 myobject.myproperty 的內容,那么我現在可以獲取接收到的動態對象并在 C# 代碼中調用 myobject.myproperty.到目前為止一切順利.

                  The JSON is automatically parsed and the resulting dynamic object is a Newtonsoft.Json.Linq.JContainer. I can, as expected, evaluate properties at runtime, so if the JSON contained something like myobject.myproperty then I can now take the dynamic object received and call myobject.myproperty within the C# code. So far so good.

                  現在我想遍歷作為 JSON 的一部分提供的所有屬性,包括嵌套屬性.但是,如果我這樣做 myobject.GetType().GetProperties() 它只返回 Newtonsoft.Json.Linq.JContainer 的屬性,而不是我正在尋找的屬性(是 JSON 的一部分).

                  Now I want to iterate over all properties that were supplied as part of the JSON, including nested properties. However, if I do myobject.GetType().GetProperties() it only returns properties of Newtonsoft.Json.Linq.JContainer instead of the properties I'm looking for (that were part of the JSON).

                  知道怎么做嗎?

                  推薦答案

                  我認為這可以作為一個起點

                  I think this can be a starting point

                  dynamic dynObj = JsonConvert.DeserializeObject("{a:1,b:2}");
                  
                  //JContainer is the base class
                  var jObj = (JObject)dynObj;
                  
                  foreach (JToken token in jObj.Children())
                  {
                      if (token is JProperty)
                      {
                          var prop = token as JProperty;
                          Console.WriteLine("{0}={1}", prop.Name, prop.Value);
                      }
                  }
                  

                  編輯

                  這也可以幫助你

                  var dict = JsonConvert.DeserializeObject<Dictionary<string, object>>(jObj.ToString());
                  

                  這篇關于動態 JContainer (JSON.NET) &amp;在運行時迭代屬性的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持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)
                    • <small id='sB10S'></small><noframes id='sB10S'>

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

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

                          <tfoot id='sB10S'></tfoot>

                              <tbody id='sB10S'></tbody>
                            主站蜘蛛池模板: 亚洲综合久久久 | 国产成人高清视频 | 欧美午夜视频 | 亚洲高清视频一区 | 日韩在线精品视频 | 亚洲精品一区二区三区蜜桃久 | 久久香蕉网| 亚洲二区在线 | 99亚洲精品| h在线免费观看 | 亚洲精品国产a久久久久久 午夜影院网站 | av网站观看 | 日韩精品久久一区二区三区 | 久草在线在线精品观看 | 久久亚洲国产 | 在线看免费| 日韩超碰 | 视频一二区| 日韩欧美一级精品久久 | 国产一伦一伦一伦 | 一级全黄少妇性色生活免费看 | 久久久tv| 国产精品亚洲二区 | 亚洲一区二区中文字幕 | 久久久久久综合 | 免费特级黄毛片 | 一区二区三区欧美在线 | 二区亚洲 | 日韩欧美亚洲 | 久久88| 欧美精品一区在线 | 国产精品久久久久久久久免费 | 国产高潮好爽受不了了夜色 | 天天插天天操 | 国产电影一区二区 | 亚洲国产精品久久久久秋霞不卡 | 国产精品亚洲精品久久 | 精品婷婷| 日韩毛片在线视频 | 国产精品一区久久久 | 成人做爰9片免费看网站 |