$\\left\" /> $\\left\" /> $\\left\"/>

Javascript JSON parse error with Latex Formular

13 views Asked by At

I want to create JSON string api with latex formular, I found that JSON.parse

can not parse Latex formular like this:

{"id":19,"question":"<p>$\\left\\{ \\begin{align}</p><p>&nbsp;&amp; 2\\left| x-1 \\right|+\\frac{y}{x+y}=6 \\\\ </p><p>&nbsp;&amp; \\left| x-1 \\right|+\\frac{x}{x+y}=1 \\\\ </p><p class=\"ql-align-justify\">\\end{align} \\right.$"}

Sample test

t = '{"id":19,"question":"<p>$\\left\\{ \\begin{align}</p><p>&nbsp;&amp; 2\\left| x-1 \\right|+\\frac{y}{x+y}=6 \\\\ </p><p>&nbsp;&amp; \\left| x-1 \\right|+\\frac{x}{x+y}=1 \\\\ </p><p class=\"ql-align-justify\">\\end{align} \\right.$"}'
JSON.parse(t)

Error message Uncaught SyntaxError: Bad escaped character in JSON at position 26 (line 1 column 27)

Tried with online JSON lint / validator, input string is true json string.

0

There are 0 answers