1d468ac35a
Signed-off-by: Sefa Eyeoglu <contact@scrumplex.net>
28 lines
686 B
C++
28 lines
686 B
C++
#include "JsonResponse.h"
|
|
|
|
#include <QByteArray>
|
|
#include <QDebug>
|
|
#include <QJsonDocument>
|
|
#include <QJsonObject>
|
|
|
|
namespace Katabasis {
|
|
|
|
QVariantMap parseJsonResponse(const QByteArray& data)
|
|
{
|
|
QJsonParseError err;
|
|
QJsonDocument doc = QJsonDocument::fromJson(data, &err);
|
|
if (err.error != QJsonParseError::NoError) {
|
|
qWarning() << "parseTokenResponse: Failed to parse token response due to err:" << err.errorString();
|
|
return QVariantMap();
|
|
}
|
|
|
|
if (!doc.isObject()) {
|
|
qWarning() << "parseTokenResponse: Token response is not an object";
|
|
return QVariantMap();
|
|
}
|
|
|
|
return doc.object().toVariantMap();
|
|
}
|
|
|
|
} // namespace Katabasis
|