Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-84495

QByteArray/QMap behaves differently with Qt 5.15 from with older versions

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Invalid
    • Icon: Not Evaluated Not Evaluated
    • None
    • 5.15.0
    • None
    • All Platforms. Qt 5.15
    • All

      I'm not sure this is a bug or intended in Qt 5.15. But this has caused problem with my code unless I apply fix in my code.

      In Qt 5.14.2, the following code:

      QVariantMap map; 
       map["Test"] = "Good"; 
       QVariantMap map2; 
       map2["json"] = QJsonDocument::fromVariant(map).toJson(QJsonDocument::Compact);
       qDebug() << QJsonDocument::fromVariant(map).toJson(QJsonDocument::Compact);
       qDebug() << QJsonDocument::fromVariant(map2).toJson(QJsonDocument::Compact);
      

       

      Will print out this:

      "\{\"Test\":\"Good\"}"
       "{\"json\":\"{\\\"Test\\\":\\\"Good\\\"}\"}"
      

      But in Qt 5.15, it will print out this:

      "\{\"Test\":\"Good\"}"
       "\{\"json\":\"eyJUZXN0IjoiR29vZCJ9\"}"
      

       

      The fix for me is pretty simple: 

      map2["json"] = QString(QJsonDocument::fromVariant(map).toJson(QJsonDocument::Compact));
      

      But still, would be nice if it works the way it worked before without having to fix the code. I want to confirm that this is not a bug but intended.

      Thanks!

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

            thiago Thiago Macieira
            wtbuck Robert Wong
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved:

                There are no open Gerrit changes