0

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?

1 Answer 1

1
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);
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.