Reputation: 3
I need to formate Json as below by using JSON.NET in C#.
[
{"curPage":1,"totalPageCount":12},
{"t0":171,"t2":"2014-12-25"},
{"t0":170,"t2":"2014-04-15"},
{"t0":169,"t2":"2014-04-15"}
]
I've already have this
List<Record> records = new Record {};
records.add(new Record());
JObject obj = new JObject(
new JProperty("c",c),
new JProperty("a",a),
new JObject(records)
);
JsonConvert.SerializeObject(obj);
class Record {
public string t0 { get; set; }
public string t2 { get; set; }
}
And I got "Could not determine JSON object type for type".
How do I deal with that?
Upvotes: 0
Views: 118
Reputation: 1927
public class Paging
{
public int CurPage { get; set; }
public int TotalPageCount { get; set; }
}
public class Item
{
public int T0 { get; set; }
public string T2 { get; set; }
}
var lst = new List<object>();
lst.Add(new Paging());
lst.Add(new Item());
JsonConvert.SerializeObject(lst);
Upvotes: 1