I am attempting to print a JSON object in string format.
(I actually retrieved these data values from Ruby code
var data = '<%=[@pro {|c| {x:c.x, y:c.y}}].to_json%>'
)
When printing the data variable, I noticed that the values contain "
instead of '
var data=[[{"x":1,"y":0}]]
I would like to have the values in the format
var data="[[{ 'x': '1', 'y': '0' }]]";
After removing "
using the code
var dataset=JSON.parse(data.replace(/"/g,'"'));
, the output is as follows:
var dataset =[[{"x":1,"y":0}]]
I want to display the values like [[{ 'x': '1', 'y': '0' }]]
. How can this be achieved?