Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Sending QJsonArray over socket
QtWS25 Last Chance

Sending QJsonArray over socket

Scheduled Pinned Locked Moved Unsolved General and Desktop
11 Posts 3 Posters 676 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Christian EhrlicherC Offline
    Christian EhrlicherC Offline
    Christian Ehrlicher
    Lifetime Qt Champion
    wrote on last edited by
    #2

    Then print out what you really receive to see if it's what you're sending. Also print out what you really send on the sender side.

    Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
    Visit the Qt Academy at https://academy.qt.io/catalog

    1 Reply Last reply
    0
    • K Offline
      K Offline
      Kris Revi
      wrote on last edited by Kris Revi
      #3

      So i did this

      void Socket::sendCommandStrip(const QString &bName, const QJsonValue bValue)
      {
          m_webSocket.sendTextMessage(QJsonDocument(QJsonObject{{bName, bValue}}).toJson(QJsonDocument::Compact));
          qDebug() << QJsonDocument(QJsonObject{{bName, bValue}}).toJson(QJsonDocument::Compact);
      }
      

      and got

      "{\"pixArt\":[]}"
      

      now my question is, why? :S

      @Christian-Ehrlicher

      if i do this

      socket.sendCommandStrip(QString("pixArt"), QJsonValue(RGB565).toArray());
      

      i get the correct output (im not copying all 16k + here)

      "{\"pixArt\":[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,30912,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,30912,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,30912,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,30912,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,30912,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,30912,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,30912,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,30912,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,30912,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,30912,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,30912,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,30912,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,30912,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,61888,
      

      it ends with this

      0,0,0,0,0,0,0,0,0]}"
      [SOCKET][INFO] We are closing the connection
      

      again it disconnects me after :S

      on the ESP32 side i get this

      Incoming data from socket!
      Empty input!
      [SOCKET][STATUS] [0] Disconnected!
      
      1 Reply Last reply
      0
      • Christian EhrlicherC Offline
        Christian EhrlicherC Offline
        Christian Ehrlicher
        Lifetime Qt Champion
        wrote on last edited by
        #4

        I said you should output what you really send, not what you pass to a function you wrote.

        Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
        Visit the Qt Academy at https://academy.qt.io/catalog

        K 1 Reply Last reply
        0
        • Christian EhrlicherC Christian Ehrlicher

          I said you should output what you really send, not what you pass to a function you wrote.

          K Offline
          K Offline
          Kris Revi
          wrote on last edited by
          #5

          @Christian-Ehrlicher that is what i send....

          qDebug() << QJsonDocument(QJsonObject{{bName, bValue}}).toJson(QJsonDocument::Compact);
          
          1 Reply Last reply
          0
          • Christian EhrlicherC Offline
            Christian EhrlicherC Offline
            Christian Ehrlicher
            Lifetime Qt Champion
            wrote on last edited by
            #6

            So what do you get on the esp side?

            Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
            Visit the Qt Academy at https://academy.qt.io/catalog

            K 1 Reply Last reply
            0
            • Christian EhrlicherC Christian Ehrlicher

              So what do you get on the esp side?

              K Offline
              K Offline
              Kris Revi
              wrote on last edited by
              #7

              @Christian-Ehrlicher the same as stated above

              Incoming data from socket!
              Empty input!
              [SOCKET][STATUS] [0] Disconnected!
              

              it claims inData['pixArt'] is empty and the disconnects me :S

              1 Reply Last reply
              0
              • Christian EhrlicherC Offline
                Christian EhrlicherC Offline
                Christian Ehrlicher
                Lifetime Qt Champion
                wrote on last edited by
                #8

                @Kris-Revi said in Sending QJsonArray over socket:

                the same as stated above

                I don't want processed output but the raw data (for the third time...)

                Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
                Visit the Qt Academy at https://academy.qt.io/catalog

                K 1 Reply Last reply
                0
                • Christian EhrlicherC Christian Ehrlicher

                  @Kris-Revi said in Sending QJsonArray over socket:

                  the same as stated above

                  I don't want processed output but the raw data (for the third time...)

                  K Offline
                  K Offline
                  Kris Revi
                  wrote on last edited by
                  #9

                  @Christian-Ehrlicher
                  like this?

                              JsonArray test = inData["pixArt"];
                  
                              Serial.println(test);
                              Serial.println(inData["pixArt"].as<JsonArray>());
                  

                  this just gives me

                  Incoming data from socket!
                  0
                  0
                  Empty input!
                  [SOCKET][STATUS] [0] Disconnected!
                  
                  JKSHJ 1 Reply Last reply
                  0
                  • Christian EhrlicherC Offline
                    Christian EhrlicherC Offline
                    Christian Ehrlicher
                    Lifetime Qt Champion
                    wrote on last edited by
                    #10

                    I'm giving up... don't know what's so hard to print out the raw incoming data. Good luck.

                    Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
                    Visit the Qt Academy at https://academy.qt.io/catalog

                    1 Reply Last reply
                    0
                    • K Kris Revi

                      @Christian-Ehrlicher
                      like this?

                                  JsonArray test = inData["pixArt"];
                      
                                  Serial.println(test);
                                  Serial.println(inData["pixArt"].as<JsonArray>());
                      

                      this just gives me

                      Incoming data from socket!
                      0
                      0
                      Empty input!
                      [SOCKET][STATUS] [0] Disconnected!
                      
                      JKSHJ Offline
                      JKSHJ Offline
                      JKSH
                      Moderators
                      wrote on last edited by
                      #11

                      @Kris-Revi said in Sending QJsonArray over socket:

                      like this?

                      No. Please show us your payload. What does it look like before you passed it into deserializeJson()? (This is what @Christian-Ehrlicher meant by "raw data")

                      Also:

                      1. What is the value of length in webSocketEvent()?
                      2. Converting an image into a QJsonArray is very expensive and inefficient. What is the purpose using QJsonArray here?

                      Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

                      1 Reply Last reply
                      2

                      • Login

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • Users
                      • Groups
                      • Search
                      • Get Qt Extensions
                      • Unsolved