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

QByteArray can no longer be passed to JSON.parse()

    XMLWordPrintable

Details

    Description

      #include <QtQml>
      
      int main(int argc, char *argv[])
      {
          QCoreApplication app(argc, argv);
      
          QQmlEngine engine;
      
          QByteArray data = "{ \"foo\":\"bar\" }";
          engine.rootContext()->setContextProperty("byteArrayData", data);
          engine.rootContext()->setContextProperty("stringData", QString::fromUtf8(data));
      
          QQmlComponent component(&engine);
          component.setData("import QtQml 2.0; QtObject { Component.onCompleted: JSON.parse(stringData) }", QUrl("string"));
          component.create(); // ok
      
          component.setData("import QtQml 2.0; QtObject { Component.onCompleted: JSON.parse(byteArrayData) }", QUrl("bytearray"));
          component.create(); // bytearray:1: JSON.parse: Parse error
      }
      

      Presumably https://codereview.qt-project.org/#/c/144761/

      Attachments

        Issue Links

          For Gerrit Dashboard: QTBUG-55562
          # Subject Branch Project Status CR V

          Activity

            People

              shausman Simon Hausmann
              jpnurmi J-P Nurmi
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes