-
-
Notifications
You must be signed in to change notification settings - Fork 6.8k
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
How to detect parse failure? #715
Comments
@nlohmann I see you saw this and added it to documentation, in the mean time while you work on it could you let me know how? I need it for a project :) |
Parse errors are indicated by exceptions. In the 2.x.x series, the exception type is |
Thank you for the quick response. Might you consider adding a simple boolean to the json object indicating whether or not there was a parse error? Sometimes it is quite inconvenient to rely on exceptions for some things. Here's a sample use-case: std::ifstream in(filename) if (j.parseError()) { print error message } |
What is inconvenient about this?
|
Nothing is inconvenient about the code itself, apologies for implying that. It is inconvenient in the case where I am working with a codebase that has exceptions disabled :( I completely understand if the feature request is not doable, just thought it wouldn't hurt to ask :) |
Oh, that's a different case altogether. #582
|
That's exactly what I'm looking for, thank you! |
it'll be interesting for newbies like me, to remind that for parsing a jsonFile from the program's argument (linux) we have to do like so : [linux] ./a.out " |
Apologies for the seemingly simple question, but there is no example for detecting a parse failure on the readme. Maybe one could be added, or a simple explanation of how to detect a parse failure could be given?
The text was updated successfully, but these errors were encountered: