Remove the deprecated Json::Reader (#1546)
This commit is contained in:
parent
f0a011b14d
commit
120aaf249d
|
@ -1,15 +1,21 @@
|
|||
#include "JsonConfigAdapter.h"
|
||||
#include <fstream>
|
||||
#include <mutex>
|
||||
|
||||
using namespace drogon;
|
||||
Json::Value JsonConfigAdapter::getJson(const std::string &content) const
|
||||
noexcept(false)
|
||||
{
|
||||
static std::once_flag once;
|
||||
static Json::CharReaderBuilder builder;
|
||||
std::call_once(once, []() { builder["collectComments"] = false; });
|
||||
JSONCPP_STRING errs;
|
||||
std::unique_ptr<Json::CharReader> reader(builder.newCharReader());
|
||||
Json::Value root;
|
||||
Json::Reader reader;
|
||||
if (!reader.parse(content, root))
|
||||
if (!reader->parse(
|
||||
content.c_str(), content.c_str() + content.size(), &root, &errs))
|
||||
{
|
||||
throw std::runtime_error("Failed to parse JSON");
|
||||
throw std::runtime_error(errs);
|
||||
}
|
||||
return root;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue