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)
project (mastobotmon
VERSION 0.3.4
VERSION 0.3.5
LANGUAGES CXX)
include(GNUInstallDirs)

View File

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