changed deprecated JSON parsing to new method

This commit is contained in:
tastytea 2018-04-11 15:46:58 +02:00
parent 1f69e0cd62
commit f12f38d951
Signed by: tastytea
GPG Key ID: 59346E0EA35C67E5
2 changed files with 7 additions and 5 deletions

View File

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

View File

@ -142,8 +142,8 @@ int main(int argc, char *argv[])
return 2; return 2;
} }
Json::Value json; Json::Value json;
Json::Reader reader; std::stringstream ss(answer);
reader.parse(answer, json); ss >> json;
const string id = json["id"].asString(); const string id = json["id"].asString();
const string straccount = json["acct"].asString() + "@" + acc.get_instance(); const string straccount = json["acct"].asString() + "@" + acc.get_instance();
write_statistics(straccount, json); write_statistics(straccount, json);
@ -155,7 +155,8 @@ int main(int argc, char *argv[])
ret = acc.get(Mastodon::API::v1::accounts_id_statuses, id, parameters, answer); ret = acc.get(Mastodon::API::v1::accounts_id_statuses, id, parameters, answer);
if (ret == 0) if (ret == 0)
{ {
reader.parse(answer, json); ss.str(answer);
ss >> json;
const string acct = json[0]["account"]["acct"].asString(); const string acct = json[0]["account"]["acct"].asString();
std::istringstream isslast(json[0]["created_at"].asString()); std::istringstream isslast(json[0]["created_at"].asString());
@ -197,7 +198,8 @@ int main(int argc, char *argv[])
ret = acc.get_mentions(answer); ret = acc.get_mentions(answer);
if (ret == 0) if (ret == 0)
{ {
reader.parse(answer, json); ss.str(answer);
ss >> json;
if (!json.empty()) if (!json.empty())
{ {
const std::uint64_t lastid = std::stoull(json[0]["id"].asString()); const std::uint64_t lastid = std::stoull(json[0]["id"].asString());