-
-
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
Syntax checking #1003
Comments
|
|
How to use this function? |
Use |
I have encountered the same issue, I could not catch anything that using Json = nlohmann::json;
//...
try {
Json::parse(data);
}
catch (const Json::parse_error &e) { //...
}
catch (const Json::exception &e) { //...
}
catch (const std::exception &e) { //...
} I don't want to open another issue, due already there's a similar one, but are there any method to get at least an error message of the reason of the failure? It is mandatory for me, because the JSON document comes directly form a user input, and have to prompt it. |
@caiwan Which version are you using? In https://nlohmann.github.io/json/classnlohmann_1_1basic__json_af1efc2468e6022be6e35fc2944cabe4d.html#af1efc2468e6022be6e35fc2944cabe4d is an example how to catch parse error exceptions. |
I've tried it with no I use the lastest stable v3.1.2 with Visual Studio 2015 (Version 14.0.25431.01 Update 3), within a Google Test testcase. If I'll have a little extra time, I'd hack together a PoC project to reproduce the issue. |
I'd be really interested, because we are using MSVC 2015 in our CI chain since we introduced the new exceptions in 3.0.0 and never heard of any issues. |
I'm need to read some *.json file, but this file can have invalid json format. How to check for right json format before or while parsing?
The text was updated successfully, but these errors were encountered: