From 92a6ce11071d970ea1dacf8f25eba1b4da847c55 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Fri, 3 Jul 2015 00:34:17 +0100 Subject: Use a std::stream over a ustring for buffering json data, better with new libjsonpp interface and fixes bytes/chars bug --- libtmdb/httpClient.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/libtmdb/httpClient.cpp b/libtmdb/httpClient.cpp index 6217f1a..a4b4eb7 100644 --- a/libtmdb/httpClient.cpp +++ b/libtmdb/httpClient.cpp @@ -41,15 +41,15 @@ namespace TMDb { static size_t appendString(void * contents, size_t size, size_t nmemb, void * userp) { - auto data = static_cast(userp); - data->append(static_cast(contents), size * nmemb); + auto data = static_cast(userp); + data->write(static_cast(contents), size * nmemb); return size * nmemb; } json::Value HttpClient::FetchJson(const std::string & path) const { - Glib::ustring jsonData; + std::stringstream jsonData; struct curl_slist *headers = NULL; curl_slist_append(headers, "Accept: application/json"); @@ -69,8 +69,7 @@ namespace TMDb { throw TMDb::HttpException(http_code); } - Glib::ustring::const_iterator itr = jsonData.begin(); - return json::parseValue(itr); + return json::parseValue(jsonData); } } -- cgit v1.2.3