title: Parsing JSON Using Newtonsoft.Json Without Knowing the Structure
body: <p>I'm working on a project that involves automating API calls using a Swagger Definition. I download the swagger.json file. The structure of the JSON Object I need to parse is not consistent. When parsing paths, there are a list of objects, then within that they have the methods that can be used for that specific path. I can retrieve just the path using various string methods but my question was, is there a good way to parse json if the JSON is structured in such a way that it does not have a firm key? Here is an example of what I mean:</p>
  
  <pre><code>{"/user": {
      "post": {
        "tags": [
          "user"
        ],
        "summary": "Create user",
        "description": "This can only be done by the logged in user.",
        "operationId": "createUser",
        "consumes": [
          "application/json"
        ],
        "produces": [
          "application/json",
          "application/xml"
        ],
        "parameters": [
          {
            "in": "body",
            "name": "body",
            "description": "Created user object",
            "required": true,
            "schema": {
              "$ref": "#/definitions/User"
            }
          }
        ],
        "responses": {
          "default": {
            "description": "successful operation"
          }
        }
      }
    }
  </code></pre>
  
  <p>If I wanted to just parse that path and retrieve the method object how could I go about that considering sometimes the object will be "post" or sometimes it will be "get", "put", etc depending on what is allowable for the path. </p>
  
  <pre><code>            JObject jsonResp = swaggerDownload();
              JObject paths = (JObject)jsonResp["paths"];
              foreach (var i in paths)
              {
                  string pathToString = i.ToString();
                  var shaveSomethings = pathToString.Substring(1, something.Length - 2);
                  var pathAndJson = shaveSomethings.Split(new[] { ',' }, 2);
                  string correctJsonStructure = "{\"" + pathAndJson[0] + "\":" + pathAndJson[1] + "}";
                  JObject bd = JObject.Parse(correctJsonStructure);
                  //dynamic pathsTest = JsonConvert.DeserializeObject&lt;dynamic&gt;(correctJsonStructure);
                  //JObject result = JsonConvert.DeserializeObject&lt;JObject&gt;(correctJsonStructure);
                  //Console.WriteLine(bd["/user"]);
  
              }
  </code></pre>
  
  <p><img src="https://i.stack.imgur.com/AlvcH.png" alt="enter image description here"></p>