aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKitsune Ral <Kitsune-Ral@users.sf.net>2017-12-06 09:07:37 +0900
committerKitsune Ral <Kitsune-Ral@users.sf.net>2017-12-06 09:07:37 +0900
commitf56edce1d27d71e5568506326468af411c78e731 (patch)
tree4cac12301a2503dd6cb85e8e1c03f31bac6c4cf3
parentd01154a1899e216b04d6fd2ad3bb384715ca843b (diff)
downloadlibquotient-f56edce1d27d71e5568506326468af411c78e731.tar.gz
libquotient-f56edce1d27d71e5568506326468af411c78e731.zip
converters.h: support QByteArray
-rw-r--r--converters.h13
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