diff --git a/launcher/Json.cpp b/launcher/Json.cpp index 37ada1aa..8f6908d3 100644 --- a/launcher/Json.cpp +++ b/launcher/Json.cpp @@ -78,6 +78,14 @@ QJsonObject requireObject(const QJsonDocument &doc, const QString &what) } return doc.object(); } +QJsonObject requireObject(const QJsonValueRef &node, const QString &what) +{ + if (!node.isObject()) + { + throw JsonException(what + " is not an object"); + } + return node.toObject(); +} QJsonArray requireArray(const QJsonDocument &doc, const QString &what) { if (!doc.isArray()) diff --git a/launcher/Json.h b/launcher/Json.h index dd70bf56..359f4757 100644 --- a/launcher/Json.h +++ b/launcher/Json.h @@ -41,6 +41,8 @@ QJsonDocument requireDocument(const QString &filename, const QString &what = "Do /// @throw JsonException QJsonObject requireObject(const QJsonDocument &doc, const QString &what = "Document"); /// @throw JsonException +QJsonObject requireObject(const QJsonValueRef &node, const QString &what = "Node"); +/// @throw JsonException QJsonArray requireArray(const QJsonDocument &doc, const QString &what = "Document"); /////////////////// WRITING ////////////////////