【问题标题】:is this c# array of array the same as this jquery array or array这个 c# 数组的数组是否与这个 jquery 数组或数组相同
【发布时间】:2014-08-02 16:10:37
【问题描述】:

这是我的 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]
    ];

?

更新 1

这是jquery中扩展数组的结果

【问题讨论】:

  • 呃,也许给我们看一下结果变量的内容而不仅仅是一张图片?在结果上使用 JSON.stringify 并将其作为文本提供给我们。如果我必须通过这张图片来判断它们可能是相同的格式..
  • @ViktorBahtev 我更新了问题
  • 格式一样。

标签: c# javascript jquery arrays


【解决方案1】:

是的,假设 Array[2] 的格式为 [Number, Number],则格式相同。从我可以看到的 C# 代码中,它正在生成您想要的格式。

【讨论】:

    猜你喜欢
    • 2015-11-25
    • 2022-07-19
    • 1970-01-01
    • 2019-04-05
    • 2021-11-08
    • 1970-01-01
    • 2019-05-26
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多