You can do it the magic way...
public class JsonListObjectController : ApiController
{
public List<DataModel> Get()
{
var data = new List<DataModel>()
{
new DataModel() {Date = DateTime.Today, Users = 100},
new DataModel() {Date = DateTime.Today, Users = 120}
};
return data;
}
}
or you can do it the "I want to stay in control way"
public HttpResponseMessage Get()
{
var data = new List<DataModel>()
{
new DataModel() {Date = DateTime.Today, Users = 100},
new DataModel() {Date = DateTime.Today, Users = 120}
};
return new HttpResponseMessage()
{
Content = new StringContent(JArray.FromObject(data).ToString(), Encoding.UTF8, "application/json")
};
}