19#ifndef JELLYFIN_SUPPORT_JSONCONVIMPL_H
20#define JELLYFIN_SUPPORT_JSONCONVIMPL_H
25#include <QJsonDocument>
29#include <QSharedPointer>
53 Q_ASSERT_X(
false,
"fromJsonValue<T>",
"fromJsonValue called with unimplemented type");
62 std::string msg =
"toJsonValue called with unimplemented type ";
63 msg +=
typeid (T).name();
64 Q_ASSERT_X(
false,
"toJsonValue<T>", msg.c_str());
83 QJsonArray arr = source.toArray();
84 result.reserve(arr.size());
85 for (
auto it = arr.constBegin(); it != arr.constEnd(); it++) {
94 for (
auto it = source.cbegin(); it != source.cend(); it++) {
104 if (source.isNull()) {
113 if (source.has_value()) {
124 if (source.isNull()) {
125 return QSharedPointer<T>();
132 if (source.isNull()) {
152 const QJsonDocument::JsonFormat format = QJsonDocument::Compact;
154 case QJsonValue::Array:
155 return QJsonDocument(val.toArray()).toJson(format);
156 case QJsonValue::Object:
157 return QJsonDocument(val.toObject()).toJson(format);
158 case QJsonValue::String:
159 return val.toString();
160 case QJsonValue::Null:
168 if (source.has_value()) {
178 tmp.reserve(source.size());
179 for (
auto it = source.cbegin(); it != source.cend(); it++) {
182 return tmp.join(
',');
Definition mediaplayer2.h:20
AccessSchedule fromJsonValue(const QJsonValue &source, convertType< AccessSchedule >)
Definition accessschedule.cpp:133
template QString toString(const QUuid &source, convertType< QUuid >)
Definition jsonconv.cpp:227
QJsonValue toJsonValue(const AccessSchedule &source, convertType< AccessSchedule >)
Definition accessschedule.cpp:139
Definition jsonconvimpl.h:45