I have this complex JSON that looks like:
{
"results": [
{
"statement_id": 0,
"series": [
{
"name": "test-name",
"tags": {
"tag1": "0"
"tag2": "1"
},
"columns": [
"time",
"mean"
],
"values": [
[
"2018-12-03T10:18:37.3Z",
0
]
]
}
]
}
]
}
The POCO for the above is like:
public class Tags
{
public string tag1 { get; set; }
public string tag2 { get; set; }
}
public class Series
{
public string name { get; set; }
public Tags tags { get; set; }
public List<string> columns { get; set; }
public List<List<object>> values { get; set; }
}
public class Result
{
public int statement_id { get; set; }
public List<Series> series { get; set; }
}
public class RootObject
{
public List<Result> results { get; set; }
}
The problem is, properties in Tags class are dynamic. There can be just one tag, 2 or more which is only determined at runtime.
I'm trying to use Newtonsoft.Json to parse this to a nested dictionary like Dictionary<string, <Dictionary<string, object[]>>> where the keys of the dictionaries are values of tags and the object[] contains the list of values (just the value, not the timestamp).
Tagsclass and instead add this as a property for the Tags?public IDictionary<string, JToken> Tags { get; set; }