How to deserialized nested jason?
Need to convert jason to csv.
[{"Parameter":[{"Name":"Truck speed","Parameter_Source_Address":"","Value":"0"},{"Name":"HP Feedback - Alt
In","Parameter_Source_Address":"","Value":"7"}],"Snapshot_DateTimestamp":"2016-10-11T14:34:09.000Z"},{"Parameter":
[{"Name":"Truck speed","Parameter_Source_Address":"","Value":"0"},{"Name":"HP Feedback - Alt
In","Parameter_Source_Address":"","Value":"7"}],"Snapshot_DateTimestamp":"2016-10-11T14:34:10.000Z"},{"Parameter":
[{"Name":"Truck speed","Parameter_Source_Address":"","Value":"0"},{"Name":"HP Feedback - Alt
In","Parameter_Source_Address":"","Value":"7"}],"Snapshot_DateTimestamp":"2016-10-11T14:34:11.000Z"},{"Parameter":
[{"Name":"Truck speed","Parameter_Source_Address":"","Value":"0"},{"Name":"HP Feedback - Alt
In","Parameter_Source_Address":"","Value":"7"}],"Snapshot_DateTimestamp":"2016-10-11T14:34:12.000Z"}]
classes
public class Parameter
{
public string Name { get; set; }
public string Parameter_Source_Address { get; set; }
public string Value { get; set; }
}
public class Snapshot
{
public List<parameter> Parameter { get; set; }
public string Snapshot_DateTimestamp { get; set; }
}
What I have tried:
var data2 = JsonConvert.DeserializeObject<list<snapshot>>(json);
Then converted list to datatable and datatable to csv.
getting output:
Parameter,Snapshot_DateTimestamp
System.Collections.Generic.List`1[Json2Csv.Parameter],2016-10-11T14:34:09.000Z
System.Collections.Generic.List`1[Json2Csv.Parameter],2016-10-11T14:34:10.000Z
System.Collections.Generic.List`1[Json2Csv.Parameter],2016-10-11T14:34:11.000Z
System.Collections.Generic.List`1[Json2Csv.Parameter],2016-10-11T14:34:12.000Z