changed deprecated JSON parsing and writing to new method
This commit is contained in:
parent
cadee6459a
commit
9b665c5a59
|
@ -1,6 +1,6 @@
|
||||||
cmake_minimum_required (VERSION 3.7)
|
cmake_minimum_required (VERSION 3.7)
|
||||||
project (mastobotmon
|
project (mastobotmon
|
||||||
VERSION 0.3.6
|
VERSION 0.3.7
|
||||||
LANGUAGES CXX)
|
LANGUAGES CXX)
|
||||||
|
|
||||||
include(GNUInstallDirs)
|
include(GNUInstallDirs)
|
||||||
|
|
|
@ -41,9 +41,7 @@ const bool read_config()
|
||||||
json << file.rdbuf();
|
json << file.rdbuf();
|
||||||
file.close();
|
file.close();
|
||||||
|
|
||||||
Json::Reader reader;
|
if (json >> config)
|
||||||
|
|
||||||
if (!reader.parse(json, config))
|
|
||||||
{
|
{
|
||||||
cerr << "ERROR: couldn't parse config file. Are you sure the JSON is well-formed?\n";
|
cerr << "ERROR: couldn't parse config file. Are you sure the JSON is well-formed?\n";
|
||||||
return false;
|
return false;
|
||||||
|
@ -148,13 +146,11 @@ const bool add_account()
|
||||||
|
|
||||||
const bool write_config()
|
const bool write_config()
|
||||||
{
|
{
|
||||||
Json::StyledWriter writer;
|
|
||||||
const string output = writer.write(config);
|
|
||||||
|
|
||||||
std::ofstream outfile(filepath);
|
std::ofstream outfile(filepath);
|
||||||
if (outfile.is_open())
|
if (outfile.is_open())
|
||||||
{
|
{
|
||||||
outfile.write(output.c_str(), output.length());
|
outfile.write(config.toStyledString().c_str(),
|
||||||
|
config.toStyledString().length());
|
||||||
outfile.close();
|
outfile.close();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
Loading…
Reference in New Issue