0

I have ViewBag.Result with string value "[['Garreth','VP'],['Johan','IT'],['Test','QA']]"

I want to convert it as javascript array

var dataset =
[
    ['Garreth','VP'],
    ['Johan','IT'],
    ['Test','QA']
]

Obviously var dataset = '@ViewBag.Result' doesn't work because javascript treat is as string but not array. Any idea how to do this?

Thanks

Amit
  • 45,440
  • 9
  • 78
  • 110
tickwave
  • 3,335
  • 6
  • 41
  • 82

1 Answers1

0

Just remove the single quotes:

var dataset = @ViewBag.Result

Amit
  • 45,440
  • 9
  • 78
  • 110