let sets = JSON . parse ( " { count: [6.3, 2.4,7.6,5.4,9.9,7.8] }" );
The above code throws an error: SyntaxError: Unexpected token c in JSON at position 3
I’ve tried both a variable string and the literal string as depicted above.
I’m trying to convert a string to a json object. Can’t get past the above error. Any help would be most appreciated.
Your string is not a valid JSON. The property count has to be a string with double quotes “count”
JSON.parse('{ "count": [6.3, 2.4,7.6,5.4,9.9,7.8] }');
let x = { count: [6.3, 2.4,7.6,5.4,9.9,7.8] };
let y = JSON.stringify(x);
let z = JSON.parse(y)
@alexanderz61239 Thank you, I tried everything except the 3 variables to get there. That works and I appreciate it!