diff options
author | Kitsune Ral <Kitsune-Ral@users.sf.net> | 2017-12-06 09:07:37 +0900 |
---|---|---|
committer | Kitsune Ral <Kitsune-Ral@users.sf.net> | 2017-12-06 09:07:37 +0900 |
commit | f56edce1d27d71e5568506326468af411c78e731 (patch) | |
tree | 4cac12301a2503dd6cb85e8e1c03f31bac6c4cf3 | |
parent | d01154a1899e216b04d6fd2ad3bb384715ca843b (diff) | |
download | libquotient-f56edce1d27d71e5568506326468af411c78e731.tar.gz libquotient-f56edce1d27d71e5568506326468af411c78e731.zip |
converters.h: support QByteArray
-rw-r--r-- | converters.h | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/converters.h b/converters.h index 733c2c0e..5593ee24 100644 --- a/converters.h +++ b/converters.h @@ -44,6 +44,11 @@ namespace QMatrixClient return QJsonArray::fromStringList(strings); } + inline QJsonValue toJson(const QByteArray& bytes) + { + return QJsonValue(static_cast<const char*>(bytes)); + } + template <typename T> struct FromJson { @@ -133,4 +138,12 @@ namespace QMatrixClient template <> struct FromJson<QStringList> : FromJson<QList<QString>> { }; + template <> struct FromJson<QByteArray> + { + QByteArray operator()(QJsonValue jv) const + { + return fromJson<QString>(jv).toLatin1(); + } + }; + } // namespace QMatrixClient |