0

I need to convert JSON data string to a JavaScript array. This my JSON data:

[["Claim","1"],["issue","4"]]

And i want to get

var data = new google.visualization.DataTable(jsonData);

        data.addColumn('string' , 'category');
        data.addColumn('number' , 'count');
        data.addRows([
            ['Claim', 1],
            ['Issue', 4]
        ]);
Faizan Ahmad
  • 355
  • 3
  • 14

2 Answers2

0

The JSON.parse() method parses a JSON string, constructing the JavaScript value or object described by the string. An optional reviver function can be provided to perform a transformation on the resulting object before it is returned.

const jsonDataStr = '[["Claim","1"],["issue","4"]]'
const jsonDataJSON = JSON.parse(jsonDataStr)

For more detail about JSON.parse(), you can see documentation

Deep Kakkar
  • 5,831
  • 4
  • 39
  • 75
Tim Wong
  • 600
  • 3
  • 9
0

var data = JSON.parse(jsonString);