From 8e2f0d5af066b67f8394a161b93d3e3be318e542 Mon Sep 17 00:00:00 2001 From: GetAway Date: Sun, 24 Mar 2019 20:51:07 +0100 Subject: [PATCH] weather.cpp: dont use deprecated Json::Reader --- src/gui/weather.cpp | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/gui/weather.cpp b/src/gui/weather.cpp index 816e842da..b14b674de 100644 --- a/src/gui/weather.cpp +++ b/src/gui/weather.cpp @@ -97,24 +97,28 @@ bool CWeather::GetWeatherDetails() return false; std::string data = "https://api.darksky.net/forecast/" + key + "/" + coords + "?units=si&lang=de&exclude=minutely,hourly,flags,alerts"; - std::string answer; + JSONCPP_STRING answer; + JSONCPP_STRING formattedErrors; + double found = 0; v_forecast.clear(); + Json::CharReaderBuilder builder; + Json::CharReader * reader = builder.newCharReader(); Json::Value DataValues; - Json::Reader DataReader; - bool parsedSuccess = false; - answer = ""; + answer.clear(); if (!getUrl(data, answer)) return false; - parsedSuccess = DataReader.parse(answer, DataValues, false); + bool parsedSuccess = reader->parse(answer.c_str(), answer.c_str() + answer.size(), &DataValues, &formattedErrors); + delete reader; + if (!parsedSuccess) { printf("Failed to parse JSON\n"); - printf("%s\n", DataReader.getFormattedErrorMessages().c_str()); + printf("%s\n", formattedErrors.c_str()); return false; }