I want to push List of type string into value dictionary in js script. Js dictionary should contain key DateTime, and List as a value.
@foreach (KeyValuePair<DateTime, List<string>> item in Model.AssignedAttractions)
{
<script type="text/javascript">
var dictionary = [];
$(function () {
dictionary.push({
key: @item.Key.ToShortDateString(),
value: @item.Value.ToArray(),
});
});
</script>
}
Presented solution value: @item.Value.ToArray()is not working.
@Html.Raw(Json.Serialize(item.Value))@using Newtonsoft.Jsonto the top of your view@Html.Raw(JsonConvert.SerializeObject(item.Value))