mirror of
https://github.com/tuxbox-neutrino/neutrino.git
synced 2025-08-29 16:31:11 +02:00
weather.cpp: dont use deprecated Json::Reader
This commit is contained in:
@@ -97,24 +97,28 @@ bool CWeather::GetWeatherDetails()
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
std::string data = "https://api.darksky.net/forecast/" + key + "/" + coords + "?units=si&lang=de&exclude=minutely,hourly,flags,alerts";
|
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;
|
double found = 0;
|
||||||
|
|
||||||
v_forecast.clear();
|
v_forecast.clear();
|
||||||
|
|
||||||
|
Json::CharReaderBuilder builder;
|
||||||
|
Json::CharReader * reader = builder.newCharReader();
|
||||||
Json::Value DataValues;
|
Json::Value DataValues;
|
||||||
Json::Reader DataReader;
|
|
||||||
bool parsedSuccess = false;
|
|
||||||
|
|
||||||
answer = "";
|
answer.clear();
|
||||||
if (!getUrl(data, answer))
|
if (!getUrl(data, answer))
|
||||||
return false;
|
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)
|
if (!parsedSuccess)
|
||||||
{
|
{
|
||||||
printf("Failed to parse JSON\n");
|
printf("Failed to parse JSON\n");
|
||||||
printf("%s\n", DataReader.getFormattedErrorMessages().c_str());
|
printf("%s\n", formattedErrors.c_str());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user