Commit aeb66147 by Ben Clayton

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.
parent 773f0dff
...@@ -14,6 +14,9 @@ ...@@ -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 { ...@@ -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) {}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment