Hello Friends 👋,
Welcome to Infinitbility.
When we stringify JSON multiple times it will add slashes in JSON and that’s why many folks getting these errors.
check the following example.
1let users = [5];67console.log(JSON.stringify(JSON.stringify(users)));89console.log(JSON.stringify(JSON.stringify(JSON.stringify(users))));
Here, I have stringify double and triple times to check their output, and here is the result.

Now, we have to same times parse the string to get actual JSON like the following example.
1let users = [5];67let userStr = JSON.stringify(JSON.stringify(JSON.stringify(users)));89console.log(userStr);1011console.log(JSON.parse(JSON.parse(JSON.parse(userStr))));
Output

but when you are an exception, and above solution not working for you.
Replace backslash to nothing in global level
Replace your backslash of every occurrence using the /\\/g
regex and javascript replace method.
After your replace try to parse your string like the following example
1let str = "{\n \"taskNames\" : [\n \"01 Jan\", \n \"02 Jan\",\n \"03 Jan\",\n \"04 Jan\", \n \"05 Jan\"\n]}"2var finial = str.replace(/\\/g, "");34console.log(JSON.parse(finial));
Output

Thanks for reading…
Follow me on Twitter
Join our email list and get notified about new content
No worries, I respect your privacy and I will never abuse your email.
Every week, on Tuesday, you will receive a list of free tutorials I made during the week (I write one every day) and news on other training products I create.