aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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