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"
|
#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>
|
#include <nlohmann/json.hpp>
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
@ -45,7 +48,8 @@ namespace dap {
|
|||||||
namespace json {
|
namespace json {
|
||||||
|
|
||||||
Deserializer::Deserializer(const std::string& str)
|
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)
|
Deserializer::Deserializer(const nlohmann::json* json)
|
||||||
: json(json), ownsJson(false) {}
|
: json(json), ownsJson(false) {}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user