Comment API error while parsing JSON
imscary opened this issue · comments
For example, if I want to parse the responeText of /api/comments/?reply_to=9006, it will fail:
Uncaught SyntaxError: Unexpected token / in JSON at position 87
at JSON.parse (<anonymous>)
at <anonymous>:1:13
The problem is at "urlized_text":"<a href="https://github.com/h/matrix" target="_blank" rel="nofollow">#matrix</a>"
The " before /h/matrix
cancels the " after href=
causing an error. The best fix is to simply change the "
in '
When I follow that link, I see "urlized_text":"<a href=\"/h/matrix\">#matrix</a>"
The quotes are properly escaped in the response, so they should parse fine.
This looks correct to me; maybe your tool is unescaping too early?
It still errors while parsing. the responseText needs to split('\\"').join('"')
to parse correctly.