diff options
author | Petr Mrázek <peterix@gmail.com> | 2014-05-11 12:37:21 +0200 |
---|---|---|
committer | Petr Mrázek <peterix@gmail.com> | 2014-06-09 01:38:30 +0200 |
commit | 69c3e7111f93290d1278d6116e9fd50079b4fe79 (patch) | |
tree | cbaed3022e8705f1da29777afea0fca16c1abe60 /logic/MMCJson.h | |
parent | 92abe4c603e1f4931cd02ae6b752cb7054d8e30d (diff) | |
download | MultiMC-69c3e7111f93290d1278d6116e9fd50079b4fe79.tar MultiMC-69c3e7111f93290d1278d6116e9fd50079b4fe79.tar.gz MultiMC-69c3e7111f93290d1278d6116e9fd50079b4fe79.tar.lz MultiMC-69c3e7111f93290d1278d6116e9fd50079b4fe79.tar.xz MultiMC-69c3e7111f93290d1278d6116e9fd50079b4fe79.zip |
Make 1.6+ work with new instance format.
Diffstat (limited to 'logic/MMCJson.h')
-rw-r--r-- | logic/MMCJson.h | 19 |
1 files changed, 19 insertions, 0 deletions
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 <typename T> +void writeObjectList (QJsonObject & to, QString key, QList<T> values) +{ + if(values.size()) + { + QJsonArray array; + for(auto value: values) + { + array.append(value->toJson()); + } + to.insert(key, array); + } +} } + |