changed deprecated JSON parsing and writing to new method

This commit is contained in:
tastytea 2018-04-11 16:03:35 +02:00
parent cadee6459a
commit 9b665c5a59
Signed by: tastytea
GPG Key ID: 59346E0EA35C67E5
2 changed files with 4 additions and 8 deletions

View File

@ -1,6 +1,6 @@
cmake_minimum_required (VERSION 3.7)
project (mastobotmon
VERSION 0.3.6
VERSION 0.3.7
LANGUAGES CXX)
include(GNUInstallDirs)

View File

@ -41,9 +41,7 @@ const bool read_config()
json << file.rdbuf();
file.close();
Json::Reader reader;
if (!reader.parse(json, config))
if (json >> config)
{
cerr << "ERROR: couldn't parse config file. Are you sure the JSON is well-formed?\n";
return false;
@ -148,13 +146,11 @@ const bool add_account()
const bool write_config()
{
Json::StyledWriter writer;
const string output = writer.write(config);
std::ofstream outfile(filepath);
if (outfile.is_open())
{
outfile.write(output.c_str(), output.length());
outfile.write(config.toStyledString().c_str(),
config.toStyledString().length());
outfile.close();
return true;