Exceptions can be switched off by defining the symbol
JSON_NOEXCEPTION. When defining
try is replaced by
catch is replaced by
if (false), and
throw is replaced by
The same effect is achieved by setting the compiler flag
By default, the macro is not defined.
what() string of exceptions is not available for MSVC if exceptions are disabled, see #2824.
The code below switches off exceptions in the library.
#define JSON_NOEXCEPTION 1 #include <nlohmann/json.hpp> ...
- Switch off exceptions for more information how to switch off exceptions
Added in version 2.1.0.
Last update: March 8, 2023