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 get indented JSON values in C++ ?
Forum Updated to NodeBB v4.3 + New Features

how to get indented JSON values in C++ ?

Scheduled Pinned Locked Moved Solved General and Desktop
jsonc++json parserqt application
12 Posts 7 Posters 5.6k Views 3 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.
  • QjayQ Offline
    QjayQ Offline
    Qjay
    wrote on last edited by
    #3

    Thanks paul colby !! It worked out .

    1 Reply Last reply
    0
    • QjayQ Offline
      QjayQ Offline
      Qjay
      wrote on last edited by
      #4

      i also want to get pageid and revid too .

      I tried this : but was not able to get the pageid :/

       jsonResponse.object()["parse"].toObject()["pageid"].toString();
      
      Joel BodenmannJ 1 Reply Last reply
      0
      • QjayQ Qjay

        i also want to get pageid and revid too .

        I tried this : but was not able to get the pageid :/

         jsonResponse.object()["parse"].toObject()["pageid"].toString();
        
        Joel BodenmannJ Offline
        Joel BodenmannJ Offline
        Joel Bodenmann
        wrote on last edited by
        #5

        The pageid value in your JSON is not a string but rather an integer, hence you have to use QJsonValue::toInt() instead of QJsonValue::toString():

        jsonResponse.object()["parse"].toObject()["pageid"].toInt();
        

        Industrial process automation software: https://simulton.com
        Embedded Graphics & GUI library: https://ugfx.io

        1 Reply Last reply
        0
        • A Offline
          A Offline
          Anil Patel
          wrote on last edited by
          #6

          Hi All,

          Need some help from you,
          How to remove "\n" between Two Json Attribute while printing .

          mrjjM Gojir4G 2 Replies Last reply
          0
          • A Anil Patel

            Hi All,

            Need some help from you,
            How to remove "\n" between Two Json Attribute while printing .

            mrjjM Offline
            mrjjM Offline
            mrjj
            Lifetime Qt Champion
            wrote on last edited by
            #7

            @Anil-Patel
            Hi
            Show how you "print" please ?

            A 1 Reply Last reply
            0
            • mrjjM mrjj

              @Anil-Patel
              Hi
              Show how you "print" please ?

              A Offline
              A Offline
              Anil Patel
              wrote on last edited by
              #8

              @mrjj {
              "app": "PromotionDngineyscad",
              "host": "WINASBAV7d7d750142-UBN",
              "log": "PromoLog",
              "lvl": "Messages",
              "msg": "Initialized",
              "thread": "237fbb2db10",
              "timestamp": "1533796312.526572",
              "uuid": "e62191c4-8891-4c92-a908-da01a3dakje3ac7ad"
              }

              jsulmJ mrjjM 2 Replies Last reply
              0
              • A Anil Patel

                @mrjj {
                "app": "PromotionDngineyscad",
                "host": "WINASBAV7d7d750142-UBN",
                "log": "PromoLog",
                "lvl": "Messages",
                "msg": "Initialized",
                "thread": "237fbb2db10",
                "timestamp": "1533796312.526572",
                "uuid": "e62191c4-8891-4c92-a908-da01a3dakje3ac7ad"
                }

                jsulmJ Offline
                jsulmJ Offline
                jsulm
                Lifetime Qt Champion
                wrote on last edited by
                #9

                @Anil-Patel You should reread the question from @mrjj

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

                1 Reply Last reply
                0
                • A Anil Patel

                  @mrjj {
                  "app": "PromotionDngineyscad",
                  "host": "WINASBAV7d7d750142-UBN",
                  "log": "PromoLog",
                  "lvl": "Messages",
                  "msg": "Initialized",
                  "thread": "237fbb2db10",
                  "timestamp": "1533796312.526572",
                  "uuid": "e62191c4-8891-4c92-a908-da01a3dakje3ac7ad"
                  }

                  mrjjM Offline
                  mrjjM Offline
                  mrjj
                  Lifetime Qt Champion
                  wrote on last edited by mrjj
                  #10

                  @Anil-Patel
                  I did mean the code :)
                  if you use printf, qDebug, or what ever.

                  You could use QString's replace if the newline are truely in the the json string.

                  1 Reply Last reply
                  0
                  • A Anil Patel

                    Hi All,

                    Need some help from you,
                    How to remove "\n" between Two Json Attribute while printing .

                    Gojir4G Offline
                    Gojir4G Offline
                    Gojir4
                    wrote on last edited by
                    #11

                    @Anil-Patel Hi,
                    Please make a new post for a new question, even more if you are not the author of the original question...

                    For your issue, I think you need to call QJsonDocument::toJson(QJsonDocument::Compact) when you export your json content to string.

                    A 1 Reply Last reply
                    2
                    • Gojir4G Gojir4

                      @Anil-Patel Hi,
                      Please make a new post for a new question, even more if you are not the author of the original question...

                      For your issue, I think you need to call QJsonDocument::toJson(QJsonDocument::Compact) when you export your json content to string.

                      A Offline
                      A Offline
                      Anil Patel
                      wrote on last edited by
                      #12

                      @Gojir4
                      Sure, Thanks for your Help.

                      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