c# - 如何使用 C# 创建 Google DataTable JSON 预期源?

标签 c# json google-visualization google-datatable

如何创建 google.visualization.datatable 所需的 JSON 源使用 C#?显然使用 JavaScriptSerializer 是不可能的,因为预期的 JSON 具有文档中描述的奇怪结构:

var dt = new google.visualization.DataTable(
     {
       cols: [{id: 'task', label: 'Task', type: 'string'},
                {id: 'hours', label: 'Hours per Day', type: 'number'}],
       rows: [{c:[{v: 'Work'}, {v: 11}]},
              {c:[{v: 'Eat'}, {v: 2}]},
              {c:[{v: 'Commute'}, {v: 2}]},
              {c:[{v: 'Watch TV'}, {v:2}]},
              {c:[{v: 'Sleep'}, {v:7, f:'7.000'}]}
             ]
     },
   0.6
)

最佳答案

虽然我不熟悉 .NET 环境,但有一个用于 Google Visualization API 的 .NET 帮助器,名为 bortosky-google-visualization .该库从 System.Data.DataTable 对象写入 JSON Google DataTable。

关于c# - 如何使用 C# 创建 Google DataTable JSON 预期源?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2363721/

相关文章:

c# - 使用 Visual Studio SDK 确定插入符号是否位于注释 block 中

javascript - Spring Ajax 列表返回但对象为空

javascript - 当数据类型混合时从 Google 电子表格访问数据

php - 如何将 MySQL 表中的数据放入 Google Chart API?

c# - 如何在第一次调用 .NET dll 时运行方法?

c# - 如何将矢量格式的图形从一个线程返回到另一个线程?

javascript - 重新调整有效 JSON 时调用的 Ajax 错误回调

javascript - 动画 Google 折线图中的新数据

c# - 检查玩家在潜行游戏中的亮度

php - 如何在 php 中访问一个 json 数组?