aboutsummaryrefslogtreecommitdiff
path: root/converters.h
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-07 11:55:07 +0900
commite9b445909f2707ca199e102e8cae2f11f7b64701 (patch)
treee627c6d42c3f0fd14654c32454ef1ea781514d9b /converters.h
parent8f762a2458db773f6db24b568b2e944427297c2b (diff)
downloadlibquotient-e9b445909f2707ca199e102e8cae2f11f7b64701.tar.gz
libquotient-e9b445909f2707ca199e102e8cae2f11f7b64701.zip
converters.h: support QByteArray
Diffstat (limited to 'converters.h')
-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