Prepare an array (in my case it is 2d array):
// prepare a 2d array in c#
ArrayList header = new ArrayList { "Task Name", "Hours"};
ArrayList data1 = new ArrayList {"Work", 2};
ArrayList data2 = new ArrayList { "Eat", 2 };
ArrayList data3 = new ArrayList { "Sleep", 2 };
ArrayList data = new ArrayList {header, data1, data2, data3};
// convert it in json
string dataStr = JsonConvert.SerializeObject(data, Formatting.None);
// store it in viewdata/ viewbag
ViewBag.Data = new HtmlString(dataStr);
Parse it in the view.
<script>
var data = JSON.parse('@ViewBag.Data');
console.log(data);
</script>
In your case you can directly use variable name instead of ViewBag.Data.