I have this object :
let startCourseData = {
'slidesHistory': '[{ id: 1, difficulty: 4, performance: 100, guided_phrases: [], sequence: "A", plan: false, planned: 10 },{ id: 2, difficulty: 4, performance: 30, guided_phrases: [], sequence: "A", plan: false, planned: 0 },{ id: 3, difficulty: 4, performance: 60, guided_phrases: [], sequence: "A", plan: false, planned: 6 },{ id: 4, difficulty: 4, performance: 80, guided_phrases: [], sequence: "B", plan: false, planned: 5 },{ id: 5, difficulty: 4, performance: 80, guided_phrases: [], sequence: "B", plan: false, planned: 6 },{ id: 6, difficulty: 4, performance: 82, guided_phrases: [], sequence: "A", plan: false, planned: 10 },{ id: 7, difficulty: 4, performance: 90, guided_phrases: [], sequence: "C", plan: false, planned: 9 },{ id: 8, difficulty: 4, performance: 90, guided_phrases: [], sequence: "C", plan: false, planned: 8 },{ id: 9, difficulty: 4, performance: 90, guided_phrases: [], sequence: "B", plan: false, planned: 5 },];'
};
And I want to convert slidesHistory that is a string to an array so I used JSON.parse like this:
const slidesHistorys = JSON.parse(startCourseData.slidesHistory);
console.log(slidesHistorys);
But I get an error!
Uncaught SyntaxError: Unexpected token i in JSON at position 3
How can I fix this?
"id: 1"or in short it is not ECMA-404 conform[{ "id": 1, "difficulty": 4, ....}]slidesHistoryinto a database as a string.. isn't it a good idea...??