这是我的c#代码,其中InBoundtable
是数据表
DateTime epoch = new DateTime(1970, 1, 1);
var result = (from row in InBoundtable.AsEnumerable()
group row by row.Field <string> ("Date") into grp
select new {
AbandonCalls = grp.Sum((r) => Double.Parse(r["AvgAbandonedCalls"].ToString())),
Date = ((DateTime.Parse(grp.Key)) - epoch).TotalMilliseconds
}).ToList();
double[][] finalArray = new double[result.Count][];
for (int i = 0; i < result.Count; i++) {
double[] tempArrayDoubel = new double[2];
tempArrayDoubel[0] = result[i].Date;
tempArrayDoubel[1] = result[i].AbandonCalls;
finalArray[i] = tempArrayDoubel;
}
我使用以下代码返回final array
:
string jsonformatstring = JsonConvert.SerializeObject(finalArray, Formatting.Indented);
HttpContext.Current.Response.Clear();
HttpContext.Current.Response.ContentType = "application/json; charset=utf-8";
HttpContext.Current.Response.Write(jsonformatstring);
HttpContext.Current.Response.End();
我将这样的网络服务称为:
$.getJSON(webServiceUrl,
{ fromDate: valFrom, toDate: valTo, sliceNumber:sliceNumber })
.done(function (result) {
console.log(result);
控制台上的结果如下:
d3 = [
[1325376000000, 650], [1328054400000, 450], [1330560000000, 150], [1333238400000, 200],
[1335830400000, 150]
];
这是在jquery中扩展数组的结果
答案 0 :(得分:0)
是的,假设Array [2]的格式为[Number,Number],则格式相同。从我所看到的C#代码中,它可以生成您想要的格式。