-
-
Notifications
You must be signed in to change notification settings - Fork 112
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
Request to expose error location-line and column #68
Comments
Send me a PR for this and I'll merge it :) |
Hi, PR as in pull request? |
yea |
mafintosh, Can you suggest what's the best way to implement this? |
Is there a purpose for this feature other than to make it easier to troubleshoot invalid JSON? When you enable verbose mode, errors include the location of specific parts of the JSON that fail validation. With this information, it should be pretty straightforward to locate the source of an issue in the JSON being validated. @Kaizer200 if you get a chance, take a look at this option and see if it meets your needs. |
I would like to mark the errors on specific lines in the editor embedded in my web-application. |
One way to accomplish that would be to create a wrapper around is-my-json-valid that would try to validate the JSON in verbose mode as mentioned above. If there is an error, check for a valid You will need some way to associate the parsed JSON object with the location of the individual tokens in the JSON itself. One way to do that would be to generate a JSON parser that would return an object that has information about the location of each of the tokens, or extract this information about the specific error-causing portion of your JSON. Things like your target speed and the input size you want to be able to handle will dictate which is more appropriate. If you want to do it client-side, jison could be used to generate the parser. The same author created jsonlint, which could be used as a basis for your parser, and you can find information on getting token locations here. After considering it for the above, and since it already provides the error location in verbose mode, I think this capability may be outside the scope of this module. What are your thoughts @mafintosh? |
Closing this based on the previous comment. |
Hi,
I would like to have additional information on every error, describing WHERE is the text in the tested JSON file/string which failed validation.
The location info should include:
line number (most important),
column number (column is were the failed text token started),
number of characters of error text token (this parameter is nice-to-have)
The text was updated successfully, but these errors were encountered: