diff options
author | rachytski <siarhei.rachytski@gmail.com> | 2012-05-12 20:41:59 +0400 |
---|---|---|
committer | Alex Zolotarev <alex@maps.me> | 2015-09-23 01:38:24 +0300 |
commit | 8c79df1dfa72e14440035a1f833556cd927596f9 (patch) | |
tree | cedd2b21cb6f1b09d8989f9a14164f15d48425f6 /platform/http_request.cpp | |
parent | c43b1b1a1ad42619d50538e43a9410db5095d8e5 (diff) |
moved ParseServerList into http_request.hpp, *.cpp
Diffstat (limited to 'platform/http_request.cpp')
-rw-r--r-- | platform/http_request.cpp | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/platform/http_request.cpp b/platform/http_request.cpp index 50a63922a7..0671f60c6d 100644 --- a/platform/http_request.cpp +++ b/platform/http_request.cpp @@ -16,6 +16,8 @@ #include "../std/scoped_ptr.hpp" +#include "../3party/jansson/myjansson.hpp" + #ifdef OMIM_OS_IPHONE #include <sys/xattr.h> @@ -313,4 +315,25 @@ HttpRequest * HttpRequest::GetFile(vector<string> const & urls, string const & f return new FileHttpRequest(urls, filePath, fileSize, onFinish, onProgress, chunkSize); } +bool ParseServerList(string const & jsonStr, vector<string> & outUrls) +{ + outUrls.clear(); + try + { + my::Json root(jsonStr.c_str()); + for (size_t i = 0; i < json_array_size(root); ++i) + { + char const * url = json_string_value(json_array_get(root, i)); + if (url) + outUrls.push_back(url); + } + } + catch (std::exception const & e) + { + LOG(LERROR, ("Can't parse server list json", e.what(), jsonStr)); + } + return !outUrls.empty(); +} + + } // namespace downloader |