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
Line numbers in tokens #146
Comments
Tokens already store their position in the input string. I see no point in implementing what you suggested as this would needlessly increase use of memory by JSMN. |
If you individually popped tokens (for example, through a callback), or if there were a way to get a more proper error message (the main structure can store the current line) on error? |
Seems like what you want is a fully featured JSON parsing library. If that's the case then I'd suggest you to look for alternatives. JSMN is quite minimalistic and has a bit of problems. |
No, not really. What I really, really appreciate about jsmn is the terseness of the library, which gives me a good indication of they way it will hold up in a security evaluation (# of LoC). My comment about the #ifdef in the typedef comes from this perspective (makes it less secure, because it may inadvertently be interpreted differently by the library compiler and the compiled-library user). My comment about the line numbering was more of me translating an end-user complaint (end-user likes to know where the parsing goes wrong), and I don't care that much about it myself. Besides - because I know the position in the JSON string, I can retroactively recover the line number anyway, by counting it myself. |
I see what you mean. But for the line numbering I'd be more interested in specific point where the error happened, not line. That's because I could have JSON data which is not neatly formatted and has a lot happening in one line. |
Something like this?
|
Line numbers could be useful, but many users of jsmn are on memory constrained systems. If such features are added, they should probably be wrapped in |
May I suggest we have line numbers in tokens? It would help greatly to debug faulty JSON files.
The text was updated successfully, but these errors were encountered: