I want to iterate through a 2D Array contents[,]
, 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.
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#:
- Create a model as mentioned here: Convert C# Object to Json Object and then convert to JSON
- Build up a nested hashtable (not dictionary because I won't know types of the values until I need to build the object)
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.?
[
{
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
]