I am facing an issue with parsing a string stored in a cookie.
"d967fac49ef2466239168bbbde0a8d755a27ba81$[[\"__json_message\"\05425\054\"This is a message.\"]]"
Also known as
"\"d967fac49ef2466239168bbbde0a8d755a27ba81$[[\\\"__json_message\\\"\\05425\\054\\\"This is a message.\\\"]]\""
(to be used in console)
Although I cannot parse it using JSON.parse and resort to eval, which poses security risks. The error message states SyntaxError: Unexpected number
.
The presence of escaped commas is noteworthy, indicating that this was generated utilizing the Django messaging API.
Can anyone suggest a suitable regex or alternative method to resolve this?
The initial step involves unescaping the string (as it is a valid JavaScript string) followed by obtaining the array after the dollar sign (s.substring(s.indexOf("$")+1)
).