Remove payload keys when no payload exists

This commit is contained in:
Richard Liebscher 2020-01-03 15:48:48 +01:00
parent 6883d46cb4
commit 5c0ad3fb85

View file

@ -87,16 +87,11 @@ QVariantMap qobject2qvariant(const T* object)
QByteArray NetworkPacket::serialize() const
{
//Object -> QVariant
//QVariantMap variant;
//variant["id"] = mId;
//variant["type"] = mType;
//variant["body"] = mBody;
QVariantMap variant = qobject2qvariant(this);
if (hasPayload()) {
//qCDebug(KDECONNECT_CORE) << "Serializing payloadTransferInfo";
variant[QStringLiteral("payloadSize")] = payloadSize();
variant[QStringLiteral("payloadTransferInfo")] = m_payloadTransferInfo;
if (!hasPayload()) {
variant.remove(QStringLiteral("payloadSize"));
variant.remove(QStringLiteral("payloadTransferInfo"));
}
//QVariant -> json