Skip to content
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 know the parse is error #1737

Closed
alongL opened this issue Sep 5, 2019 · 2 comments
Closed

how to know the parse is error #1737

alongL opened this issue Sep 5, 2019 · 2 comments
Labels
kind: question solution: proposed fix a fix for the issue has been proposed and waits for confirmation

Comments

@alongL
Copy link

alongL commented Sep 5, 2019

string str = ""; //give a empty string
auto j3 = json::parse(str); //exceptin occours

auto j4 = json::parse(str, nullptr, false); //no exception
j4["action"];  //exception  occours

How to know the parse is right?

@nlohmann
Copy link
Owner

nlohmann commented Sep 5, 2019

When you switch off exceptions as you did when parsing to j4, the result type will be discarded in case of a parse error (see documentation of parse). You can check this with j4.is_discarded() which should be true.

@nlohmann nlohmann added the solution: proposed fix a fix for the issue has been proposed and waits for confirmation label Sep 5, 2019
@alongL
Copy link
Author

alongL commented Sep 7, 2019

ok. Problem Solved

@nlohmann nlohmann closed this as completed Sep 8, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind: question solution: proposed fix a fix for the issue has been proposed and waits for confirmation
Projects
None yet
Development

No branches or pull requests

2 participants