Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Comment API error while parsing JSON #372

Open
imscary opened this issue Aug 6, 2018 · 3 comments
Open

Comment API error while parsing JSON #372

imscary opened this issue Aug 6, 2018 · 3 comments

Comments

@imscary
Copy link
Contributor

imscary commented Aug 6, 2018

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="/h/matrix">#matrix</a>"
The " before /h/matrix cancels the " after href= causing an error. The best fix is to simply change the " in '

@joeysino
Copy link

joeysino commented Aug 6, 2018

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.

@lionleaf
Copy link
Owner

lionleaf commented Aug 7, 2018

This looks correct to me; maybe your tool is unescaping too early?

@imscary
Copy link
Contributor Author

imscary commented Aug 7, 2018

It still errors while parsing. the responseText needs to split('\\"').join('"') to parse correctly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants