0

I am working on a PHP application developed using Zend 2.2.4 with SQL Server database. Currently I am working on saving and retrieving JSON data from the database. I use the following line to encode the array in JSON format and then save it to the database:

$reportData = json_encode($reportData);

I can retrieve the data from the database but not sure if it's being formatted in JSON format. I displayed the contents of the JSON values in JavScript using 'console.log' and the output seems fine:

reportData: "{"chartData":[{"name":"test","data":[1,2,3]}],"pieData":[{"name":"test-2","type":"pie","data":[[2,4,1],]}]}"

But if I try console.log(reportData.chartData), I get an 'undefined' message in the console.

Can someone kindly advise on what I'm doing wrong please? Appreciate any help.

Aaron Bertrand
  • 261,961
  • 36
  • 448
  • 471
Mr B
  • 3,760
  • 7
  • 43
  • 70

0 Answers0