Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Solved Json (C++) error

    General and Desktop
    4
    5
    134
    Loading More Posts
    • 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.
    • S
      Szabii last edited by

      Hello!

      Before I added [] elements inside X1/X2/Y1/Y2 Coords, the following code was good:

      QJsonArray maps = QJsonDocument::fromJson(val.toUtf8()).array();
      

      But now, it gives back an empty array... How can I solve this problem? Thank u in advance!

      alt text

      JKSH 1 Reply Last reply Reply Quote 0
      • JKSH
        JKSH Moderators @Szabii last edited by

        Hi, and welcome!

        @Szabii said in Json (C++) error:

        But now, it gives back an empty array... How can I solve this problem?

        Your JSON document contains errors (look closely at "Colors"). Copy and paste your document into https://jsonlint.com/ to locate the errors.

        Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

        1 Reply Last reply Reply Quote 7
        • Christian Ehrlicher
          Christian Ehrlicher Lifetime Qt Champion last edited by

          @JKSH said in Json (C++) error:

          to locate the errors.

          Or use the Qt Api: QJsonDocument::fromJson() and check for errors instead simply hoping that all goes fine.

          Qt has to stay free or it will die.

          1 Reply Last reply Reply Quote 5
          • mrjj
            mrjj Lifetime Qt Champion last edited by

            Nice catch. I didnt see the missing ,
            before i read the comment.

            1 Reply Last reply Reply Quote 1
            • S
              Szabii last edited by

              Thanks the help! Really worked :D Kinda new in Json.

              1 Reply Last reply Reply Quote 1
              • First post
                Last post