json_serializer: Disable exceptions
Define `JSON_NOEXCEPTION` to avoid raising exceptions. Exceptions are usually disabled for Google projects (https://google.github.io/styleguide/cppguide.html#Exceptions). Also pass `false` to the `allow_exceptions` parameter of `nlohmann::json::parse()`. Issue identified by @kuafuwang in #26.
This commit is contained in:
parent
773f0dff68
commit
aeb66147da
@ -14,6 +14,9 @@
|
||||
|
||||
#include "json_serializer.h"
|
||||
|
||||
// Disable JSON exceptions. We should be guarding against any exceptions being
|
||||
// fired in this file.
|
||||
#define JSON_NOEXCEPTION 1
|
||||
#include <nlohmann/json.hpp>
|
||||
|
||||
namespace {
|
||||
@ -45,7 +48,8 @@ namespace dap {
|
||||
namespace json {
|
||||
|
||||
Deserializer::Deserializer(const std::string& str)
|
||||
: json(new nlohmann::json(nlohmann::json::parse(str))), ownsJson(true) {}
|
||||
: json(new nlohmann::json(nlohmann::json::parse(str, nullptr, false))),
|
||||
ownsJson(true) {}
|
||||
|
||||
Deserializer::Deserializer(const nlohmann::json* json)
|
||||
: json(json), ownsJson(false) {}
|
||||
|
Loading…
x
Reference in New Issue
Block a user