Open
Description
What happened?
There is the following functions in the include/jwt-cpp/traits/nlohmann-json/traits.h header file.
static bool parse(json& val, std::string str) {
val = json::parse(str.begin(), str.end());
return true;
}
This function uses json::parse with exceptions, an uncaught exception is generated when handling bad input.
Could you please refer to the following nlohmann-json official example? Thank you.
// parse with exceptions
try
{
json j = json::parse(text);
}
catch (json::parse_error& e)
{
std::cout << e.what() << std::endl;
}
// parse without exceptions
json j = json::parse(text, nullptr, false);
if (j.is_discarded())
{
std::cout << "the input is invalid JSON" << std::endl;
}
else
{
std::cout << "the input is valid JSON: " << j << std::endl;
}
How To Reproduce?
No response
Version
0.6.0
What OS are you seeing the problem on?
Linux
What compiler are you seeing the problem on?
GCC
Relevant log output
No response
Code of Conduct
- I agree to follow this project's Code of Conduct