Reputation: 658
I have json object.when i do JSON.stringify it looks like below
{
"bindto": {},
"data": {
"type": "line",
"columns": "[['SO_Lat',1361.213042,7494.897354000001],['SO_Long',1361.213042,7494.897354000001]]",
}
}
I want to convert column field without double quotes and send it back to server my final output will be like this
{
"bindto": {},
"data": {
"type": "line",
"columns": [['SO_Lat',1361.213042,7494.897354000001],['SO_Long',1361.213042,7494.897354000001]],
}
}
Please help
Upvotes: 0
Views: 4304
Reputation: 22325
Oh boy this is hacky.
obj.data.columns = JSON.parse('{"x":' + obj.data.columns.replace(/'/g, '"') + '}').x
That string isn't JSON, so this basically forces it to be JSON and parses it. Barely better than an eval.
Upvotes: 3