summaryrefslogtreecommitdiffstats
path: root/logic/MMCJson.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'logic/MMCJson.cpp')
-rw-r--r--logic/MMCJson.cpp23
1 files changed, 22 insertions, 1 deletions
diff --git a/logic/MMCJson.cpp b/logic/MMCJson.cpp
index 65423436..f7b4b6b0 100644
--- a/logic/MMCJson.cpp
+++ b/logic/MMCJson.cpp
@@ -11,7 +11,7 @@ bool MMCJson::ensureBoolean(const QJsonValue val, const QString what)
QJsonValue MMCJson::ensureExists(QJsonValue val, const QString what)
{
- if(val.isNull())
+ if(val.isUndefined() || val.isUndefined())
throw JSONValidationError(what + " does not exist");
return val;
}
@@ -59,3 +59,24 @@ QString MMCJson::ensureString(const QJsonValue val, const QString what)
return val.toString();
}
+void MMCJson::writeString(QJsonObject &to, QString key, QString value)
+{
+ if(value.size())
+ {
+ to.insert(key, value);
+ }
+}
+
+void MMCJson::writeStringList(QJsonObject &to, QString key, QStringList values)
+{
+ if(values.size())
+ {
+ QJsonArray array;
+ for(auto value: values)
+ {
+ array.append(value);
+ }
+ to.insert(key, array);
+ }
+}
+