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 I can create Json Format in Qt ?
QtWS25 Last Chance

How I can create Json Format in Qt ?

Scheduled Pinned Locked Moved Unsolved General and Desktop
jsonqjsondocument
7 Posts 3 Posters 1.5k 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.
  • N Offline
    N Offline
    npatil15
    wrote on 9 Jul 2019, 11:53 last edited by
    #1

    I have an example, but not getting how I can create it.

    {
      "Version" : "1.0",
      "tap" : { },
      "notation" : {  },
      "definition" : 
         [
            {
              "tag":1,
              "Name" : "view1"
            }
    
            {
              "tag":2,
              "Name" : "view2"
            }
         ]
      "images" : 
         {
            "File" : "image.png",
            "Index" : 0,
            "Properties" : [ "black", "bold"]
         }
    }
    

    Please give me an sample example which help me to create this.

    J 1 Reply Last reply 9 Jul 2019, 11:55
    0
    • N npatil15
      9 Jul 2019, 11:53

      I have an example, but not getting how I can create it.

      {
        "Version" : "1.0",
        "tap" : { },
        "notation" : {  },
        "definition" : 
           [
              {
                "tag":1,
                "Name" : "view1"
              }
      
              {
                "tag":2,
                "Name" : "view2"
              }
           ]
        "images" : 
           {
              "File" : "image.png",
              "Index" : 0,
              "Properties" : [ "black", "bold"]
           }
      }
      

      Please give me an sample example which help me to create this.

      J Offline
      J Offline
      jsulm
      Lifetime Qt Champion
      wrote on 9 Jul 2019, 11:55 last edited by
      #2

      @npatil15 Please take a look at https://doc.qt.io/qt-5/json.html first
      You will even find a link to an example there...

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      4
      • N Offline
        N Offline
        npatil15
        wrote on 10 Jul 2019, 09:50 last edited by
        #3

        Hi @jsulm,

        That also has the same example but not find how to create it.

        J 1 Reply Last reply 10 Jul 2019, 10:26
        0
        • N npatil15
          10 Jul 2019, 09:50

          Hi @jsulm,

          That also has the same example but not find how to create it.

          J Offline
          J Offline
          jsulm
          Lifetime Qt Champion
          wrote on 10 Jul 2019, 10:26 last edited by
          #4

          @npatil15 Sorry, I'm not going to write code for you to create exact the JSON document you want to write. Read documentation, take a look at axamples and think about hot to create such a JSON document.

          https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          4
          • M Offline
            M Offline
            mrjj
            Lifetime Qt Champion
            wrote on 10 Jul 2019, 11:13 last edited by mrjj 7 Oct 2019, 11:14
            #5

            Hi
            As a starter.
            To build a json document, you insert the various json types that make up the structure.

            like

               QJsonDocument doc;
            
                QJsonObject root;
                QJsonObject someObj;
            // create an array and put a double and object in it
                QJsonArray array;
                array.append( QJsonValue(32.4) );
                array.append( someObj );
            // add some properties to the root object
                root["intValue"] = 1;
            // add empty object
                root["SomeEmptyObject"] = someObj;
            //add the array
                root["somearray"] = array;
            // set to the document
                doc.setObject(root);
                qDebug().noquote().nospace() << doc.toJson();
            
            {  
               "SomeEmptyObject":{  
            
               },
               "intValue":1,
               "somearray":[  
                  32.4,
                  {  
            
                  }
               ]
            }
            
            1 Reply Last reply
            4
            • N Offline
              N Offline
              npatil15
              wrote on 11 Jul 2019, 04:39 last edited by
              #6

              @mrjj said in How I can create Json Format in Qt ?:

              someObj

              Thanks, it helps a lot.

              1 Reply Last reply
              0
              • N Offline
                N Offline
                npatil15
                wrote on 11 Jul 2019, 05:32 last edited by
                #7
                This post is deleted!
                1 Reply Last reply
                0

                7/7

                11 Jul 2019, 05:32

                • Login

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