mirror of
https://github.com/tristanpenman/valijson.git
synced 2024-12-13 10:32:58 +01:00
Switched from jsoncpp deprecated Reader to CharReader
This commit is contained in:
parent
45a333e60d
commit
ccad6b140f
@ -1,6 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
|
||||
#include <json/json.h>
|
||||
|
||||
@ -18,14 +19,14 @@ inline bool loadDocument(const std::string &path, Json::Value &document)
|
||||
return false;
|
||||
}
|
||||
|
||||
Json::Reader reader;
|
||||
bool parsingSuccessful = reader.parse(file, document);
|
||||
if (!parsingSuccessful) {
|
||||
std::cerr << "Jsoncpp parser failed to parse the document:" << std::endl
|
||||
<< reader.getFormattedErrorMessages();
|
||||
const auto fileLength = static_cast<int>(file.length());
|
||||
Json::CharReaderBuilder builder;
|
||||
const std::unique_ptr<Json::CharReader> reader(builder.newCharReader());
|
||||
std::string err;
|
||||
if (!reader->parse(file.c_str(), file.c_str() + fileLength, &document, &err)) {
|
||||
std::cerr << "Jsoncpp parser failed to parse the document:" << std::endl << err;
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user