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. Assign RAW JSON data to QbyteArray
Qt 6.11 is out! See what's new in the release blog

Assign RAW JSON data to QbyteArray

Scheduled Pinned Locked Moved Solved General and Desktop
3 Posts 3 Posters 417 Views 2 Watching
  • 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.
  • D Offline
    D Offline
    Damian7546
    wrote on last edited by Damian7546
    #1

    Hi,
    How assign to my QbyteArray , data raw JSON data?

    QByteArray data = "{ "status": "SOLD", "date": "2022-02-19 21:15:00"}"
    

    In this way doesn't work..

    sierdzioS M 2 Replies Last reply
    0
    • D Damian7546

      Hi,
      How assign to my QbyteArray , data raw JSON data?

      QByteArray data = "{ "status": "SOLD", "date": "2022-02-19 21:15:00"}"
      

      In this way doesn't work..

      sierdzioS Offline
      sierdzioS Offline
      sierdzio
      Moderators
      wrote on last edited by
      #2

      @Damian7546 said in Assign RAW JSON data to QbyteArray:
      You just need to escape the quotes, does not matter if you assign to byte array, string or any other type.

      QByteArray data = "{ \"status\": \"SOLD\", \"date\": \"2022-02-19 21:15:00\"}"
      

      (Z(:^

      1 Reply Last reply
      2
      • D Damian7546 has marked this topic as solved on
      • D Damian7546

        Hi,
        How assign to my QbyteArray , data raw JSON data?

        QByteArray data = "{ "status": "SOLD", "date": "2022-02-19 21:15:00"}"
        

        In this way doesn't work..

        M Offline
        M Offline
        mpergand
        wrote on last edited by
        #3

        @Damian7546
        or use raw string:

        QByteArray data = R"({ "status": "SOLD", "date": "2022-02-19 21:15:00"})";
        qDebug().noquote()<<data;
        
        1 Reply Last reply
        4

        • Login

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