[Development] QJsonDocument Compact output

Knight Andrew Andrew.Knight at digia.com
Wed Feb 19 15:42:07 CET 2014


Already fixed. https://codereview.qt-project.org/#change,78163

From: development-bounces+andrew.knight=digia.com at qt-project.org [mailto:development-bounces+andrew.knight=digia.com at qt-project.org] On Behalf Of Richard Gerd Kuesters
Sent: 19 February 2014 16:40
To: development at qt-project.org
Subject: [Development] QJsonDocument Compact output

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.



More information about the Development mailing list