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. Parsing multiple json data
Forum Updated to NodeBB v4.3 + New Features

Parsing multiple json data

Scheduled Pinned Locked Moved General and Desktop
5 Posts 2 Posters 2.3k 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
    gandiii
    wrote on last edited by
    #1

    Hi,

    can somebody help to parse my json string:
    @{"id":1}
    {"id":2}
    ...
    @

    How can I go through this objects with QJson (Qt 5)?
    thx.

    1 Reply Last reply
    0
    • JKSHJ Offline
      JKSHJ Offline
      JKSH
      Moderators
      wrote on last edited by
      #2

      Hi,

      See http://qt-project.org/doc/qt-5/qjsondocument.html#fromJson

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

      1 Reply Last reply
      0
      • G Offline
        G Offline
        gandiii
        wrote on last edited by
        #3

        I know how to parse json.
        But if I try:
        QJsonDocument::fromJson
        then object()
        I only get the first json element.

        1 Reply Last reply
        0
        • JKSHJ Offline
          JKSHJ Offline
          JKSH
          Moderators
          wrote on last edited by
          #4

          [quote author="gandiii" date="1392638439"]
          @
          {"id":1}
          {"id":2}
          ...
          @

          ...
          But if I try:
          QJsonDocument::fromJson
          then object()
          I only get the first json element.
          [/quote]Sorry, I didn't read your original question and title properly.

          Since you have multiple JSON documents in your string, I guess you'll have to split them into multiple strings and feed them into multiple QJsonDocuments.

          You can detect the start and end of the documents by counting the number of '{' and '}' characters as you iterate through your original string.

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

          1 Reply Last reply
          0
          • G Offline
            G Offline
            gandiii
            wrote on last edited by
            #5

            bq. You can detect the start and end of the documents by counting the number of ‘{’ and ‘}’ characters as you iterate through your original string.bq.

            thx
            i will give it a try

            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