From 69c3e7111f93290d1278d6116e9fd50079b4fe79 Mon Sep 17 00:00:00 2001 From: Petr Mrázek Date: Sun, 11 May 2014 12:37:21 +0200 Subject: Make 1.6+ work with new instance format. --- logic/MMCJson.h | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'logic/MMCJson.h') diff --git a/logic/MMCJson.h b/logic/MMCJson.h index 71ded435..8408f29b 100644 --- a/logic/MMCJson.h +++ b/logic/MMCJson.h @@ -43,4 +43,23 @@ int ensureInteger(const QJsonValue val, QString what = "value"); /// make sure the value is converted into a double precision floating number. throw otherwise. double ensureDouble(const QJsonValue val, QString what = "value"); + +void writeString(QJsonObject & to, QString key, QString value); + +void writeStringList (QJsonObject & to, QString key, QStringList values); + +template +void writeObjectList (QJsonObject & to, QString key, QList values) +{ + if(values.size()) + { + QJsonArray array; + for(auto value: values) + { + array.append(value->toJson()); + } + to.insert(key, array); + } +} } + -- cgit