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
  • 43,881
  • 8
  • 73
  • 106
warheat1990
  • 3,107
  • 5
  • 33
  • 67

1 Answers1

0

Just remove the single quotes:

var dataset = @ViewBag.Result

Amit
  • 43,881
  • 8
  • 73
  • 106