title: C#: How do you build semi-structured objects analogous to JSON?
body: <p>I want to iterate through a 2D Array <code>contents[,]</code>, and build up a JSON-like object as a do so. The structure is like below. This will then be sent to a server endpoint, processed by a server-side function and stored into a database.</p>
  
  <p>In JavaScript this would have been straightforward, but that is because typing is dynamic. As far as I can tell, I have two options for building up sem-structured data in C#:</p>
  
  <ol>
  <li>Create a model as mentioned here: <a href="https://stackoverflow.com/questions/34862072/convert-c-sharp-object-to-json-object">Convert C# Object to Json Object</a> and then convert to JSON</li>
  <li>Build up a nested hashtable (not dictionary because I won't know types of the values until I need to build the object)</li>
  </ol>
  
  <p>What is the normal way of doing this in C#? I have also come across the term 'POCO', which seems to somewhat correspond to point 1.?</p>
  
  <pre><code>[
      {
          tableName: someName,
          fields: [ordered, list, of, field, names],
          values: [
              [ordered, list, of, cell, row, values],
              [ordered, list, of, cell, row, values],
              [ordered, list, of, cell, row, values]
          ]
      },
      {
          tableName: someName,
          fields: [ordered, list, of, field, names],
          values: [
              [ordered, list, of, cell, row, values],
              [ordered, list, of, cell, row, values],
              [ordered, list, of, cell, row, values]
          ]
      },
      etc
  ]
  </code></pre>