1. <tfoot id='ymyPM'></tfoot>

  2. <small id='ymyPM'></small><noframes id='ymyPM'>

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

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

      如何从 Json.NET 获取密钥列表?

      时间:2023-08-24
        <tbody id='RnXti'></tbody>

    2. <tfoot id='RnXti'></tfoot>

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

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

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

                本文介绍了如何从 Json.NET 获取密钥列表?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                问题描述

                我正在使用 C# 和 Json.NET.如果我有一个 JObject,我想要一个对象内键的列表,类似于 object.Keys() 如何返回对象内的键.这似乎很明显,但我很难找到一种方法来做到这一点.

                I'm using C# and Json.NET. If I have a JObject, I want a list of the keys within the object, similar to how object.Keys() returns the keys within the object. This seems like it'd be obvious, but I'm having a rough time finding a way to do this.

                我正在遍历对象,我想在遍历时吐出对象中的所有键.我意识到这个例子会导致多次看到同一个键,这符合我的需要.

                I'm traversing through the object, and I want to spit out all the keys in the object as I go through. I realize that this example will result in seeing the same key multiple times, and that's OK for my needs.

                public void SomeMethod(JObject parent) {
                    foreach (JObject child in parent.Children()) {
                        if (child.HasValues) {
                        //
                        // Code to get the keys here
                        //
                        SomeMethod(child);
                        }
                    }
                }
                

                推荐答案

                IList<string> keys = parent.Properties().Select(p => p.Name).ToList();
                

                文档:JObject.Properties

                这篇关于如何从 Json.NET 获取密钥列表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                上一篇:检测到自引用循环 - 从 WebApi 取回数据到浏览器 下一篇:在 Newtonsoft.Json 中处理十进制值

                相关文章

                最新文章

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

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

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

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