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

Add in JSON Array

Scheduled Pinned Locked Moved Solved General and Desktop
11 Posts 6 Posters 1.9k 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.
  • M Offline
    M Offline
    Mikeeeeee
    wrote on last edited by
    #1

    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?

    sneubertS 1 Reply Last reply
    0
    • M Mikeeeeee

      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?

      sneubertS Offline
      sneubertS Offline
      sneubert
      wrote on 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 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
        • sneubertS Offline
          sneubertS Offline
          sneubert
          wrote on 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
          • mrjjM Offline
            mrjjM Offline
            mrjj
            Lifetime Qt Champion
            wrote on 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 last edited by
              #6

              My version 5.11.2

              json file can occupy several gigabytes

              jsulmJ 1 Reply Last reply
              0
              • M Mikeeeeee

                My version 5.11.2

                json file can occupy several gigabytes

                jsulmJ Offline
                jsulmJ Offline
                jsulm
                Lifetime Qt Champion
                wrote on 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 last edited by
                  #8

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

                  mrjjM 1 Reply Last reply
                  0
                  • M Mikeeeeee

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

                    mrjjM Offline
                    mrjjM Offline
                    mrjj
                    Lifetime Qt Champion
                    wrote on 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
                    • Christian EhrlicherC Online
                      Christian EhrlicherC Online
                      Christian Ehrlicher
                      Lifetime Qt Champion
                      wrote on 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

                      sierdzioS 1 Reply Last reply
                      0
                      • Christian EhrlicherC Christian Ehrlicher

                        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)

                        sierdzioS Offline
                        sierdzioS Offline
                        sierdzio
                        Moderators
                        wrote on 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

                        • Login

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