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. Add in JSON Array

Add in JSON Array

Scheduled Pinned Locked Moved Solved General and Desktop
11 Posts 6 Posters 1.9k 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.
  • M Mikeeeeee
    30 Oct 2018, 10:59

    Hi!
    There is the array in json-file. In need to add ther other element of this array. But it takes a lot of time to load whole array. How can I add one element quickly?

    S Offline
    S Offline
    sneubert
    wrote on 30 Oct 2018, 11:46 last edited by
    #2

    Hi @Mikeeeeee,

    please provide some more information. Do you use QJsonDocument or javascript JSON in qml? Can you provide a minimal example?

    1 Reply Last reply
    2
    • M Offline
      M Offline
      Mikeeeeee
      wrote on 30 Oct 2018, 14:47 last edited by
      #3

      Yes, I use QJsonDocument. There is only one array in json file. There is QString LastResume in my project. I would like to add LastResume in the array in json file. But json file may be is large. That's why I don't want load the whole file.

      1 Reply Last reply
      0
      • S Offline
        S Offline
        sneubert
        wrote on 30 Oct 2018, 15:04 last edited by
        #4

        Since JSON is a text file, you maybe faster in creating two QTextStream, one for reading your JSON file, and one for writing to a new file. You can process the input file line by line until you hit the array end character ], where you can insert your string. This is kind of change by copy. But I don“t know if this is really faster, you have to try.

        Maybe someone else here has experience in modifying large files. Maybe this can be faster with memory mapping the file?

        1 Reply Last reply
        2
        • M Offline
          M Offline
          mrjj
          Lifetime Qt Champion
          wrote on 30 Oct 2018, 18:46 last edited by
          #5

          Hi
          What Qt version are you using ?
          The array must be ULTRA huge for it to take time.
          https://bugreports.qt.io/browse/QTBUG-44737

          so i wonder if its older Qt version.

          1 Reply Last reply
          4
          • M Offline
            M Offline
            Mikeeeeee
            wrote on 31 Oct 2018, 08:32 last edited by
            #6

            My version 5.11.2

            json file can occupy several gigabytes

            J 1 Reply Last reply 31 Oct 2018, 08:42
            0
            • M Mikeeeeee
              31 Oct 2018, 08:32

              My version 5.11.2

              json file can occupy several gigabytes

              J Offline
              J Offline
              jsulm
              Lifetime Qt Champion
              wrote on 31 Oct 2018, 08:42 last edited by
              #7

              @Mikeeeeee said in Add in JSON Array:

              json file can occupy several gigabytes

              !
              Wondering what the use case for such huge JSON file is...

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

              1 Reply Last reply
              3
              • M Offline
                M Offline
                Mikeeeeee
                wrote on 31 Oct 2018, 10:17 last edited by
                #8

                I predicted to use it for saving array. But I desided to use SQL.

                M 1 Reply Last reply 31 Oct 2018, 10:24
                0
                • M Mikeeeeee
                  31 Oct 2018, 10:17

                  I predicted to use it for saving array. But I desided to use SQL.

                  M Offline
                  M Offline
                  mrjj
                  Lifetime Qt Champion
                  wrote on 31 Oct 2018, 10:24 last edited by
                  #9

                  @Mikeeeeee
                  Using SQL is way better as a JSON file this size will consume TONS of memory with a DOM parser like QJsonDocument.

                  1 Reply Last reply
                  1
                  • C Offline
                    C Offline
                    Christian Ehrlicher
                    Lifetime Qt Champion
                    wrote on 31 Oct 2018, 10:52 last edited by
                    #10

                    QJson also has an internal memory limit which is imo below 1GB. There was a thread about this on the mailing list some months ago (during the cbor introduction iirc)

                    Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
                    Visit the Qt Academy at https://academy.qt.io/catalog

                    S 1 Reply Last reply 31 Oct 2018, 10:54
                    0
                    • C Christian Ehrlicher
                      31 Oct 2018, 10:52

                      QJson also has an internal memory limit which is imo below 1GB. There was a thread about this on the mailing list some months ago (during the cbor introduction iirc)

                      S Offline
                      S Offline
                      sierdzio
                      Moderators
                      wrote on 31 Oct 2018, 10:54 last edited by
                      #11

                      @Christian-Ehrlicher said in Add in JSON Array:

                      QJson also has an internal memory limit which is imo below 1GB. There was a thread about this on the mailing list some months ago (during the cbor introduction iirc)

                      That limit (128 MB) is for saving to binary JSON only, if I recall correctly.

                      (Z(:^

                      1 Reply Last reply
                      0

                      11/11

                      31 Oct 2018, 10:54

                      • Login

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