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.