title: How to traverse dynamic nested json in c# recursively
body: <p>If dataGeneratorType is range then the value can be anything between dataGeneratorStart and dataGeneratorEnd. If dataGeneratorType is array with no length property then the value will be one value randomly selected from the array, otherwise it be two randomly selected values that equals to the length. If it is the object (which can be more nested) then it will again follow the above logic. But this is where it gets tricky for me. Is there any dynamic way to solve the problem in C#.   </p>
  
  <p>Input payload json</p>
  
  <pre><code>{
      "temperature": {
          "type": "int",
          "dataGeneratorType": "range",
          "dataGeneratorStart": -5,
          "dataGeneratorEnd": 55
      },
      "salesAmount": {
          "type": "float",
          "dataGeneratorType": "array",
          "dataGeneratorArray": [
              0.51,
              13.33,
              20.01,
              1.54
          ]
      },
      "city": {
          "type": "string",
          "dataGeneratorType": "array",
          "dataGeneratorArray": [
              "UK",
              "Iceland",
              "Portugal",
              "Spain"
          ]
      },
      "relatedTags": {
          "type": "array",
          "dataGeneratorType": "array",
          "dataGeneratorArray": [
              "Sport",
              "Hardware",
              "Cycling",
              "Magazines"
          ],
          "length": 2
      },
      "salesDetail": {
          "type": "object",
          "dataGeneratorType": "object",
          "dataGeneratorValue": {
              "VAT": {
                  "type": "float",
                  "dataGeneratorType": "range",
                  "dataGeneratorStart": 0.0,
                  "dataGeneratorEnd": 20.0
              },
              "discountAmount": {
                  "type": "float",
                  "dataGeneratorType": "array",
                  "dataGeneratorArray": [
                      0.10,
                      0.15,
                      0.20
                  ]
              }
          }
      }
  }
  </code></pre>
  
  <p>To output json:</p>
  
  <pre><code>{
      "temperature": 20,
      "salesAmount": 20.01,
      "city": "Iceland",
      "relatedTags": [
          "Sport",
          "Cycling"
      ],
      "salesDetails": {
          "VAT": 15.0,
          "discount": 0.1
      }
  }
  </code></pre>