I'm trying to parse some JSON, but it seems I have bad control characters, even though http://jsonlint.com indicates it's valid. What would I need to change for it to be actually valid?
{"panes": [{"col": {"3": 1}, "row": {"3": 1}, "width": 1, "widgets": [{"type": "Slider", "settings": {"max": 100, "min": 0, "step": 1, "color": "grey", "onSlide": "// Example: Convert temp from C to F and truncate to 2 decimal places.\n// return (datasources[\"MyDatasource\"].sensor.tempInF * 1.8 + 32).toFixed(2);\n\n", "showvalue": 1, "initialvalue": "0"}}], "col_width": 1}], "columns": null, "plugins": [], "version": 1, "allow_edit": true, "datasources": []}
This is the output form JSONLint, which indicates its Valid JSON. When trying to parse it using JSON.parse(), I get the folling error:
SyntaxError: JSON.parse: bad control character in string literal at line 1 column 235 of the JSON data
{
"panes": [{
"col": {
"3": 1
},
"row": {
"3": 1
},
"width": 1,
"widgets": [{
"type": "Slider",
"settings": {
"max": 100,
"min": 0,
"step": 1,
"color": "grey",
"onSlide": "// Example: Convert temp from C to F and truncate to 2 decimal places.\n// return (datasources[\"MyDatasource\"].sensor.tempInF * 1.8 + 32).toFixed(2);\n\n",
"showvalue": 1,
"initialvalue": "0"
}
}],
"col_width": 1
}],
"columns": null,
"plugins": [],
"version": 1,
"allow_edit": true,
"datasources": []
}
I was trying to parse a php object property.
var js_object = JSON.parse('<?= php_object->json ?>');