I'm having trouble with QJsonDocument::fromVariant() is not handling arrays:

        QVariant list;

        QList<QVariantMap> letters {
                        QVariantMap {{"a",1}},
                        QVariantMap {{"b",2}},
                        QVariantMap {{"c",3}}
        };

        list.setValue(letters);
        map["err"] = QVariant(); // null
        map["letters"] = list;

        qDebug() << QJsonDocument::fromVariant(map)
                                .toJson(QJsonDocument::Compact);

Output:
{"err":null,"letters":null}

I'm expecting:
{"err":null,"letters":[{"a": 1},{"b": 2},{"c": 3}]}

The debugger (screenshot attached) sees it. Is this a bug or am I doing it 
wrong?
_______________________________________________
Interest mailing list
Interest@qt-project.org
https://lists.qt-project.org/listinfo/interest

Reply via email to