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. Json (C++) error

Json (C++) error

Scheduled Pinned Locked Moved Solved General and Desktop
5 Posts 4 Posters 380 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.
  • S Offline
    S Offline
    Szabii
    wrote on last edited by
    #1

    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

    JKSHJ 1 Reply Last reply
    0
    • S Szabii

      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

      JKSHJ Offline
      JKSHJ Offline
      JKSH
      Moderators
      wrote on last edited by
      #2

      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
      7
      • Christian EhrlicherC Online
        Christian EhrlicherC Online
        Christian Ehrlicher
        Lifetime Qt Champion
        wrote on last edited by
        #3

        @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 Online Installer direct download: https://download.qt.io/official_releases/online_installers/
        Visit the Qt Academy at https://academy.qt.io/catalog

        1 Reply Last reply
        5
        • mrjjM Offline
          mrjjM Offline
          mrjj
          Lifetime Qt Champion
          wrote on last edited by
          #4

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

          1 Reply Last reply
          1
          • S Offline
            S Offline
            Szabii
            wrote on last edited by
            #5

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

            1 Reply Last reply
            1

            • Login

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