我想在WEBAPI中创建JSON响应。以下是JSON的POCO格式。我想把它变成asp.net WEB API。 这太令人困惑了。请帮助我。提前谢谢
public class LstDateUsage
{
public int carrierId { get; set; }
public double data { get; set; }
public string date { get; set; }
public double minutes { get; set; }
public double sms { get; set; }
}
public class LstWeekUsage
{
public int carrierId { get; set; }
public double data { get; set; }
public List<LstDateUsage> lstDateUsages { get; set; }
public double minutes { get; set; }
public double sms { get; set; }
public string week { get; set; }
}
public class LstMonthUsage
{
public int carrierId { get; set; }
public double data { get; set; }
public List<LstWeekUsage> lstWeekUsages { get; set; }
public double minutes { get; set; }
public string month { get; set; }
public double sms { get; set; }
}
public class LstQuarterUsage
{
public int carrierId { get; set; }
public double data { get; set; }
public List<LstMonthUsage> lstMonthUsages { get; set; }
public double minutes { get; set; }
public string quarter { get; set; }
public double sms { get; set; }
}
public class Year
{
public int carrierId { get; set; }
public double data { get; set; }
public List<LstQuarterUsage> lstQuarterUsages { get; set; }
public double minutes { get; set; }
public double sms { get; set; }
public string year { get; set; }
}
public class RootObject
{
public int carrierId { get; set; }
public List<Year> years { get; set; }
}
为了创建JSON,我有这种格式的样本输入数据
Date, Type, Usage, Provider
2015-01-01 00:00:00.000 3 7 2983903
2015-01-02 00:00:00.000 3 7 3898111
2015-01-03 00:00:00.000 3 7 1569424
2015-01-04 00:00:00.000 2 7 4305933
2015-01-05 00:00:00.000 3 7 3995045
2015-01-06 00:00:00.000 3 7 2902631
2015-01-07 00:00:00.000 1 8 3962638
2015-01-08 00:00:00.000 3 8 731317
2015-01-09 00:00:00.000 1 7 1769561
2015-01-10 00:00:00.000 3 8 4333871
2015-01-11 00:00:00.000 3 7 1940508
Here 1=SMS,2=Voice,3=Data ,7=A1, 8=A2
we have to process the output on one-year records.
So, for 365 days of 3 type will be 1045 records for one provider,
if we count for two providers then it will be approx 2090 rows in SQL server .