I have a JSON string that I got from the table, here's my JSON
{"subtitle":"Information","desc":"Hi, Welcome.\\n <br><br>\\n You can access our website <a href=\\"https://test.com\\">here</a>.\\n <br><br>\\n Dont forget, cost: only $2! \\n <br>\\n <br>\\n <br>\\n <br>\\n Thankyou,<br>\\n Regards"}
when I'm trying to do json.parse()
but I got an error
SyntaxError: Unexpected token h in JSON at position 154.
I thought it caused because of the quotes "
in URL or colon :
.
How do I can pass them to JSON?
Update
Here's how I got the data:
var body_inbox = {};
body_inbox.subtitle = 'Information';
body_inbox.desc = `Hi, Welcome.
<br><br>
You can access our website <a href="https://test.com">here</a>.
<br><br>
Dont forget, cost: only $2!
<br>
<br>
<br>
<br>
Thankyou,<br>
Regards`;
body_inbox = JSON.stringify(body_inbox);
I am confused, I found many data in table that data has double backslash in newline \\n
and in url <a href=\\"https://test.com\\">here</a>
. I just try create new data with JSON.stringify and the result is \n
and <a href=\"https://test.com\">here</a>
. Why does this happen?
Note
Sorry, there's a misleading the earlier data is typo.
It should be <a href=\\"https://test.com\\">
not <a href="\\https://test.com\\">