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. How to convert a QJsonObject to a QString
Forum Updated to NodeBB v4.3 + New Features

How to convert a QJsonObject to a QString

Scheduled Pinned Locked Moved General and Desktop
4 Posts 3 Posters 15.4k Views 1 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.
  • G Offline
    G Offline
    gogo000
    wrote on last edited by
    #1

    I have a QJsonObject data and want to convert to QString. How can I do this? Searched for help in Qt, it only can convert QJsonObject to QVariantMap...

    Thanks in advance.

    1 Reply Last reply
    0
    • W Offline
      W Offline
      wrosecrans
      wrote on last edited by
      #2

      You need to get a QJsonValue, which has a .toString() method. That or you need to use QJsonDocument to turn a whole object into a string.

      @QString jsonToString(QJsonObject json)
      {

      QJsonDocument Doc(json);
      QByteArray ba = Doc.toJson();
      return QString(ba);
      

      }@

      1 Reply Last reply
      1
      • A Offline
        A Offline
        andre
        wrote on last edited by
        #3

        Indeed. Go through QJsonDocument.

        1 Reply Last reply
        0
        • G Offline
          G Offline
          gogo000
          wrote on last edited by
          #4

          Thank you, I will try that.

          1 Reply Last reply
          0

          • Login

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