[Development] QJsonDocument Compact output

Richard Gerd Kuesters richard at humantech.com.br
Wed Feb 19 15:39:57 CET 2014


Hello all!

I have a question about QJsonDocument, specially in the "Compact" format.

To illustrate better, first the code and its output:

<code>
int main()
{
     QJsonDocument qjd;
     QJsonObject qjo;
     qjo.insert("foo", QJsonValue(QString("bar")));
     qjo.insert("num", QJsonValue(1));

     qjd.setObject(qjo);
     qDebug() << "-- Idented Output ---";
     qDebug() << qjd.toJson(QJsonDocument::Indented);
     qDebug() << "-- Compact Output ---";
     qDebug() << qjd.toJson(QJsonDocument::Compact);
     return 0;
}
</code>

<output>
-- Idented Output ---
"{
     "foo": "bar",
     "num": 1
}
"
-- Compact Output ---
"{"foo": "bar","num": 1}"
</output>

The question is:why QJsonDocument::Compact doesn't rip off extra spaces 
between the colon and value? Like: *`"num":1`*instead of `*"num":_1*` ? 
It doesn't make sense, at least for me (this behavior).


Best regards,
Richard.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/development/attachments/20140219/79c01a6a/attachment.html>


More information about the Development mailing list