Add in JSON Array
-
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?Hi @Mikeeeeee,
please provide some more information. Do you use
QJsonDocument
or javascript JSON in qml? Can you provide a minimal example? -
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?
-
Hi
What Qt version are you using ?
The array must be ULTRA huge for it to take time.
https://bugreports.qt.io/browse/QTBUG-44737so i wonder if its older Qt version.
-
@Mikeeeeee said in Add in JSON Array:
json file can occupy several gigabytes
!
Wondering what the use case for such huge JSON file is... -
@Mikeeeeee
Using SQL is way better as a JSON file this size will consume TONS of memory with a DOM parser like QJsonDocument. -
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)
-
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)
@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.