summaryrefslogtreecommitdiff
path: root/src/convert_json.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/convert_json.cpp')
-rw-r--r--src/convert_json.cpp39
1 files changed, 14 insertions, 25 deletions
diff --git a/src/convert_json.cpp b/src/convert_json.cpp
index c5c69d93c..cea089623 100644
--- a/src/convert_json.cpp
+++ b/src/convert_json.cpp
@@ -30,45 +30,34 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "httpfetch.h"
#include "porting.h"
-Json::Value fetchJsonValue(const std::string &url,
- std::vector<std::string> *extra_headers) {
-
- HTTPFetchRequest fetchrequest;
- HTTPFetchResult fetchresult;
- fetchrequest.url = url;
- fetchrequest.caller = HTTPFETCH_SYNC;
+Json::Value fetchJsonValue(const std::string &url,
+ std::vector<std::string> *extra_headers)
+{
+ HTTPFetchRequest fetch_request;
+ HTTPFetchResult fetch_result;
+ fetch_request.url = url;
+ fetch_request.caller = HTTPFETCH_SYNC;
if (extra_headers != NULL)
- fetchrequest.extra_headers = *extra_headers;
+ fetch_request.extra_headers = *extra_headers;
- httpfetch_sync(fetchrequest,fetchresult);
+ httpfetch_sync(fetch_request, fetch_result);
- if (!fetchresult.succeeded) {
+ if (!fetch_result.succeeded) {
return Json::Value();
}
Json::Value root;
Json::Reader reader;
- std::istringstream stream(fetchresult.data);
+ std::istringstream stream(fetch_result.data);
- if (!reader.parse( stream, root ) )
- {
+ if (!reader.parse(stream, root)) {
errorstream << "URL: " << url << std::endl;
errorstream << "Failed to parse json data " << reader.getFormattedErrorMessages();
- errorstream << "data: \"" << fetchresult.data << "\"" << std::endl;
+ errorstream << "data: \"" << fetch_result.data << "\"" << std::endl;
return Json::Value();
}
- if (root.isArray()) {
- return root;
- }
- if ((root["list"].isArray())) {
- return root["list"];
- }
- else {
- return root;
- }
-
- return Json::Value();
+ return root;
}
std::vector<ModStoreMod> readModStoreList(Json::Value& modlist) {