I am having issues figuring out how to parse a JSON response that I am getting back from a 3rd party. I need to convert from the following JSON (a simplified example of what I am getting back) to a C# class. The main issue is that the columns may be in a different order, have extra fields, or missing ones (Which should just end up as null values).
{
"columns": [
{ "id": { "type": "Numeric", "nullable": false } },
{ "name": { "type": "Text", "nullable": false } },
{ "description": { "type": "Text", "nullable": true } },
{ "last_updated": { "type": "DateTime", "nullable": false } }
],
"rows": [
[1, "foo", "Lorem ipsum", "2016-10-26T00:09:14Z"],
[4, "bar", null, "2013-07-01T13:04:24Z"]
]
}
The C# class for this example would be
public class Record
{
public int id { get; set; }
public string name { get; set; }
public string description { get; set; }
public DateTime? last_updated { get; set; }
}
I have tried using a custom json converter, but did not have much luck getting it to work with the separated metadata and values. Does anyone have any ideas on how to go about parsing this kind of data? Eventually there will be multiple "Record" types, which is why the response from the server can be dynamic.