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
Forum Update on Monday, May 27th 2025

Sending QJsonArray over socket

Scheduled Pinned Locked Moved Unsolved General and Desktop
11 Posts 3 Posters 687 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.
  • C Online
    C Online
    Christian Ehrlicher
    Lifetime Qt Champion
    wrote on 14 Apr 2021, 17:48 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 14 Apr 2021, 18:15 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
      • C Online
        C Online
        Christian Ehrlicher
        Lifetime Qt Champion
        wrote on 14 Apr 2021, 18:42 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 14 Apr 2021, 18:50
        0
        • C Christian Ehrlicher
          14 Apr 2021, 18:42

          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 14 Apr 2021, 18:50 last edited by
          #5

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

          qDebug() << QJsonDocument(QJsonObject{{bName, bValue}}).toJson(QJsonDocument::Compact);
          
          1 Reply Last reply
          0
          • C Online
            C Online
            Christian Ehrlicher
            Lifetime Qt Champion
            wrote on 14 Apr 2021, 18:56 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 14 Apr 2021, 19:02
            0
            • C Christian Ehrlicher
              14 Apr 2021, 18:56

              So what do you get on the esp side?

              K Offline
              K Offline
              Kris Revi
              wrote on 14 Apr 2021, 19:02 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
              • C Online
                C Online
                Christian Ehrlicher
                Lifetime Qt Champion
                wrote on 14 Apr 2021, 19:03 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 14 Apr 2021, 19:15
                0
                • C Christian Ehrlicher
                  14 Apr 2021, 19:03

                  @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 14 Apr 2021, 19:15 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!
                  
                  J 1 Reply Last reply 14 Apr 2021, 22:44
                  0
                  • C Online
                    C Online
                    Christian Ehrlicher
                    Lifetime Qt Champion
                    wrote on 14 Apr 2021, 19:19 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
                      14 Apr 2021, 19:15

                      @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!
                      
                      J Offline
                      J Offline
                      JKSH
                      Moderators
                      wrote on 14 Apr 2021, 22:44 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

                      11/11

                      14 Apr 2021, 22:44

                      • Login

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