fojas / cleverbot-node

Cleverbot client in node.js
MIT License
62 stars 33 forks source link

Unexpected token in json #32

Closed ghost closed 7 years ago

ghost commented 7 years ago

So sometimes my bot errors with unexpected token found in JSON... Error can be found here https://sentry.io/share/issue/3133353338302e323234363239343030/

shantanuthatte commented 7 years ago

I'm experiencing the same issue too.

ghost commented 7 years ago

I added a pull request to fix that problem. Just a simple backslash remover function xD

Ballasi commented 7 years ago

Got the same problem here, tried using your pull req but it doesn't work for me ( /\/s aren't accepted for me, tried using /\\/s but doesn't work either). Managed to do it by doing a simple .split('\\').join(' ') which is weird, but which works.

fojas commented 7 years ago

Sorry. I might not have time to push a new release to npm today.

Do you have a copy of the JSON that is failing? I wonder if I can submit it to the folks at Cleverbot to see if their API is returning malformed JSON.

Thanks!

Ballasi commented 7 years ago

There you go. http://pastebin.com/rmGRGjYY

Ballasi commented 7 years ago

Also found out that -logically- Cleverbot doesn't like when we're using "s. Adding a replace for them in the message part could be wiser.

shantanuthatte commented 7 years ago

Testing this out.. It also sometimes breaks on the new emojis.. Needs more testing

From the string \test\\\. I can say that the JSON returned is not escaped for input and successive fields. Maybe Cleverbot can fix this?

fojas commented 7 years ago

I pushed a new version that I think should fix it. Please try now.