> Sent: Tuesday, June 08, 2021 at 4:23 PM > From: "Jason H" <jh...@gmx.com> > To: "interestqt-project.org" <interest@qt-project.org> > Subject: [Interest] QJsonDocument::fromVariant failing with list > > 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}]}
So it looks like it works with: QList<QVariant> letters {...} It seems like QList<QVariantMap> vs QList<QVariant> should have the same behavior as each other? _______________________________________________ Interest mailing list Interest@qt-project.org https://lists.qt-project.org/listinfo/interest