[Development] State of "binary JSON" in 5.15+?
thiago.macieira at intel.com
Fri Apr 16 00:32:43 CEST 2021
On Thursday, 15 April 2021 13:49:30 PDT Stottlemyer, Brett (B.S.) wrote:
> No, your description is correct. Thanks for helping to clarify.
> Does this help Thiago? I'm not using JSON as an input to sending a QString
> or QByteArray over the wire, I want to read a file from disk (quickly) and
> find or extract specific elements from the document.
Yes, it helps.
No, your use-case won't be efficient the way you described. The in-memory
representation of QJsonDocument has changed, so attempting to save and
reloading as binary JSON will instead now make it worse. Just keep the
QJsonDocument / QJsonValue that the thing was about, or keep the CBOR or JSON
The memory consumption of the CBOR-based in-memory format should be
comparable, at least at first approximation, for reasonably-nested structures.
The QCborContainerPrivate structure that is the backend of everything is
designed to minimise the overhead and it also keeps your strings in US-ASCII
as much as possible (most of your JSON object keys will be US-ASCII).
If you REALLY need the binary format, you can try to use the qt5compat module
in Qt 5. You may need to rename or namespace the class, since QtCore does
export classes by the same name and you don't want an ODR violation.
Thiago Macieira - thiago.macieira (AT) intel.com
Software Architect - Intel DPG Cloud Engineering
More information about the Development