Currently, I am in the process of developing a chatApp for my portfolio. I am working with technologies such as Flask on the back-end and vanilla on the front-end to gain a better understanding of how everything works. My main goal is to display events based on sockets for new users.
When transmitting a list of objects from the Flask back-end to Jinja2 and then manipulating it in a JS file by converting it to a JSON file, I keep encountering errors. Despite trying various REGEX methods to replace single quotes with double quotes and tildes in different combinations, I am still facing issues. Below are some images showcasing the problem I am experiencing.
// Make sure that i parsed an string not object...
let json = JSON.stringify(loggedUsers.textContent.trim());
console.log(json);
//json = jsonCorecter(json);
json = json.replace(/"/g, "`");
json = json.replace(/'/g, '"');
json = json.replace(/`/g, "'");
console.log(json);
console.log(typeof(json));
json = JSON.parse(json);
console.log(json);
console.log(typeof(json));