zaach / jsonlint

A JSON parser and validator with a CLI.
http://zaach.github.com/jsonlint/
1.94k stars 420 forks source link

[Feature Request] More helpful error message when single quotes detected #119

Open agilgur5 opened 5 years ago

agilgur5 commented 5 years ago

If you use single quotes, it will (confusingly) tell you "expected STRING, got undefined". Single quotes are in fact strings, but invalid JSON, and therefore a very common error (see #46 , and https://github.com/getinsomnia/insomnia/issues/1150), so I think a more informative error message would be much more helpful.

prantlf commented 5 years ago

You could add single quotes to the lexer and instead of recognising them as string declarators, you would just make the tokenisation fail. I did something similar for JavaScript-like comments, so that they could be either ignored, or reported by a better error message.

agilgur5 commented 5 years ago

Oh cool, thanks for the suggestion @prantlf !

Good luck on the fork and hope it does well! I also maintain a heavily updated fork of a library :)