msg["params"] = ctx;
QJsonObject obj = QJsonObject::fromVariantMap(msg);
QJsonDocument doc(obj);
- QByteArray msg_bytes = doc.toJson();
+ QByteArray msg_bytes = doc.toJson(QJsonDocument::Compact);
QByteArray packet;
QDataStream stream(&packet, QIODevice::WriteOnly);
- stream << msg_bytes.constData();
+ // Use writeBytes rather than << to avoid putting the null terminator from
+ // msg_bytes in the packet.
+ stream.writeBytes(msg_bytes.constData(), msg_bytes.length());
//qDebug() << "Would send" << packet.toHex();
// No queueing, no blocking, no reliable delivery, no frills.
foreach (RibbonSocket* s , sockets) {