How send a QJsonObject using QWebChannel in Qt
<p>Im implementing a HTML wrapper in Qt using QWebChannel, and im sucessifully able to send string, but, i woud like to send a QJsonObject, Not a json string like "{a:1,b:2}" but a Qt QJsonObject. Is it possible? </p>

<p>the official documentation says</p>

<blockquote>
  <p>"No manual message passing and serialization of data is required,"
   <a href="http://doc.qt.io/qt-5/qwebchannel.html" rel="nofollow">http://doc.qt.io/qt-5/qwebchannel.html</a></p>
</blockquote>

<p>How can I emit a signal with a JsonObject  instead of a string?</p>

<p>This is my QWebChannel connected class</p>

<pre><code>class Mapa : public QObject{
    Q_OBJECT

    public:
        explicit Mapa();
        displayMessage(const QString &amp;message);
    signals:
        updateText(const QString &amp;text); // success :sends text
        updateJson( const QJsonObject   &amp;json); // fail: sends null
        updateJsond(const QJsonDocument &amp;jsondoc);// fail: sends null
    }
 }
</code></pre>

<p>and here is my main code</p>

<pre><code>Mapa map;
// setup the channel
QWebChannel channel;
QObject::connect(&amp;clientWrapper, &amp;WebSocketClientWrapper::clientConnected, &amp;channel, &amp;QWebChannel::connectTo);

// setup the dialog and publish it to the QWebChannel
channel.registerObject(QStringLiteral("map"), &amp;map);

map.updateText("text");// sends "text" string

QJsonObject j;
j["Altitude"]  = 10;

map.updateJson(j); // sends "null" string
QJsonDocument doc(j);
map.updateJsond(doc); // sends "null" string
</code></pre>