When attempting to insert a JSON in localStorage, I am encountering the error
Unexpected token ~ in JSON at position 3
during the parse process.
Here is how I am inserting the data into localStorage:
localStorage.setItem(
"users",
`"[\"~#iM\",[\"loading\",false,\"auth\"]]"`
);
However, in localStorage, the data appears as:
"["~#iM",["loading",false,"auth"]]"
Attempting to parse it using:
JSON.parse("["~#iM",["loading",false,"auth"]]")
results in an error, while using:
JSON.parse("[\"~#iM\",[\"loading\",false,\"auth\"]]")
works correctly. The presence of \
is crucial. How can I maintain them in localStorage?