From 3c16b0159ba9a881924340011f5ddaf94672ef7b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20A=C3=9Fmus?= Date: Sun, 24 Aug 2014 19:21:05 +0200 Subject: [PATCH] HaikuDepot: Use JSON parser provided by Augustin to parse response. --- src/apps/haikudepot/WebAppInterface.cpp | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/apps/haikudepot/WebAppInterface.cpp b/src/apps/haikudepot/WebAppInterface.cpp index c4bae2989a..fe1f01775a 100644 --- a/src/apps/haikudepot/WebAppInterface.cpp +++ b/src/apps/haikudepot/WebAppInterface.cpp @@ -10,6 +10,7 @@ #include #include #include +#include #include #include #include @@ -284,13 +285,18 @@ WebAppInterface::RetrievePackageInfo(const BString& packageName, request.Result()); int32 statusCode = result.StatusCode(); - - if (statusCode == 200) - return B_OK; + if (statusCode != 200) { + printf("Response code: %" B_PRId32 "\n", statusCode); + return B_ERROR; + } - printf("Response code: %" B_PRId32 "\n", statusCode); + jsonString.SetTo(static_cast(replyData.Buffer()), + replyData.BufferLength()); + if (jsonString.Length() == 0) + return B_ERROR; - return B_ERROR; + BJson parser; + return parser.Parse(message, jsonString); }