title: Create json object with multiple array in c#
body: <p>I want to create JSON object with following format:-</p>
  
  <pre><code>{
    "result": [
        {
          "name": "John",
          "address": "US",
        },
        {
          "name": "Josh",
          "address": "Japan",
        }
    ],
    "error": [
      {
        "message": "error-message"
      }
    ],
    "success": [
      {
        "message": "success-message"
      }
    ]
  }
  </code></pre>
  
  <p>I have tried the following, but it doesn't help me.</p>
  
  <pre><code>dynamic record = new { result = new {name="", address=""},
                     error = new {message=""},
                     success = new {message=""} };
  </code></pre>
  
  <p><strong>Update 1:-</strong></p>
  
  <p>Here is my code:-
          List addressList = new List();</p>
  
  <pre><code>  // Loop over items within the container and URI.
      foreach (var item in items)
      {
          dynamic record = new { result = new object[] {
      new {name = item.name, address = item.address} } };
          addressList.Add(record);
  
      }
  </code></pre>
  
  <p>Result:-</p>
  
  <pre><code>[  {
      "result": [
        {
          "name": "John",
          "address": "US"
        }
      ]
    },
    {
      "result": [
        {
          "name": "Jack",
          "address": "CA"
        }
      ]
    }
  ]
  </code></pre>
  
  <p>Expected json result:-</p>
  
  <pre><code>  [{
          "result": [{
              "name": "John",
              "address": "US"
          }]
      },
      {
          "result": [{
              "name": "Jack",
              "address": "CA"
          }],
          "error": [{
              "message": "error-message"
          }],
          "success": [{
              "message": "success-message"
          }]
      }
  ]
  </code></pre>
  
  <p>How do I update my code to get above expected json result?</p>