aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKitsune Ral <Kitsune-Ral@users.sf.net>2017-11-01 17:42:57 +0300
committerKitsune Ral <Kitsune-Ral@users.sf.net>2017-11-01 17:42:57 +0300
commitc4e1e0906558608326210eb333b0beb73636de60 (patch)
treecd5abf797bdaa93a18a9b52423392900722c2cf9
parent2931b4d13e1883150b92f80f08aa51d86ac2445f (diff)
downloadlibquotient-c4e1e0906558608326210eb333b0beb73636de60.tar.gz
libquotient-c4e1e0906558608326210eb333b0beb73636de60.zip
Add fromJson<QList<QString>> and fromJson<QStringList>
-rw-r--r--converters.h15
1 files changed, 15 insertions, 0 deletions
diff --git a/converters.h b/converters.h
index f6e850c6..733c2c0e 100644
--- a/converters.h
+++ b/converters.h
@@ -118,4 +118,19 @@ namespace QMatrixClient
return vect;
}
};
+
+ template <typename T> struct FromJson<QList<T>>
+ {
+ QList<T> operator()(QJsonValue jv) const
+ {
+ const auto jsonArray = jv.toArray();
+ QList<T> sl; sl.reserve(jsonArray.size());
+ std::transform(jsonArray.begin(), jsonArray.end(),
+ std::back_inserter(sl), FromJson<T>());
+ return sl;
+ }
+ };
+
+ template <> struct FromJson<QStringList> : FromJson<QList<QString>> { };
+
} // namespace QMatrixClient