Description
Problem is when QVariant contains value of QJsonValue, QJsonObject or QJsonArray type.
QJsonValue::fromVariant() will then try to use conversion to String and if it fails it will return Null QJsonValue.
Example:
#include <QCoreApplication> #include <QVariant> #include <QJsonValue> #include <QDebug> int main(int argc, char *argv[]) { QCoreApplication a(argc, argv); QJsonValue jsonValue(1); QVariant var(jsonValue); qDebug() << var; // output: QVariant(QJsonValue, QJsonValue(double, 1) ) qDebug() << QJsonValue::fromVariant(var); // output: QJsonValue(null) return 0; }
It would be much better if this could work in more natural way.
Converting QVarinat containing one of QJsonValue types should result into QJsonValue of same type.
Attachments
For Gerrit Dashboard: QTBUG-41234 | ||||||
---|---|---|---|---|---|---|
# | Subject | Branch | Project | Status | CR | V |
109075,3 | Fix QJsonValue::fromVariant() if the variant contains a json object | 5.6 | qt/qtbase | Status: MERGED | +2 | 0 |