diff options
-rw-r--r-- | converters.h | 15 |
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 |