From e9f10a7f0e6a1a847cec978b3ad7b28bea1ca6cf Mon Sep 17 00:00:00 2001 From: GetAway Date: Sun, 24 Mar 2019 22:57:49 +0100 Subject: [PATCH] weather.cpp: dont use deprecated Json::Reader Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/b23d3f06c1fedda59e08a9f3ba526a2170f5e322 Author: GetAway Date: 2019-03-24 (Sun, 24 Mar 2019) ------------------ No further description and justification available within origin commit message! ------------------ This commit was generated by Migit --- 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 077f42da3..95bbca51f 100644 --- a/src/gui/weather.cpp +++ b/src/gui/weather.cpp @@ -98,24 +98,28 @@ bool CWeather::GetWeatherDetails() return false; std::string data = "https://api.darksky.net/forecast/" + key + "/" + coords + "?units=ca&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; }