weather.cpp: dont use deprecated Json::Reader

Origin commit data
------------------
Branch: ni/coolstream
Commit: b23d3f06c1
Author: GetAway <get-away@t-online.de>
Date: 2019-03-24 (Sun, 24 Mar 2019)


------------------
No further description and justification available within origin commit message!

------------------
This commit was generated by Migit
This commit is contained in:
GetAway
2019-03-24 22:57:49 +01:00
committed by vanhofen
parent bce4c6faa8
commit e9f10a7f0e

View File

@@ -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;
}