Name Description Size Coverage
qbinaryjson.cpp ! \namespace QBinaryJson \inmodule QtCore5Compat \brief Contains functions for converting QJsonDocument to and from JSON binary format. This namespace provides utility functions to keep compatibility with older code, which uses the JSON binary format for serializing JSON. Qt JSON types can be converted to Qt CBOR types, which can in turn be serialized into the CBOR binary format and vice versa. 21210 -
qbinaryjson.h 1087 -
qbinaryjson_p.h This defines a binary data structure for Json data. The data structure is optimised for fast reading and minimum allocations. The whole data structure can be mmap'ed and used directly. In most cases the binary structure is not as space efficient as a utf8 encoded text representation, but much faster to access. The size requirements are: String: Latin1 data: 2 bytes header + string.length() Full Unicode: 4 bytes header + 2*(string.length()) Values: 4 bytes + size of data (size can be 0 for some data) bool: 0 bytes double: 8 bytes (0 if integer with less than 27bits) string: see above array: size of array object: size of object Array: 12 bytes + 4*length + size of Value data Object: 12 bytes + 8*length + size of Key Strings + size of Value data For an example such as { // object: 12 + 5*8 = 52 "firstName": "John", // key 12, value 8 = 20 "lastName" : "Smith", // key 12, value 8 = 20 "age" : 25, // key 8, value 0 = 8 "address" : // key 12, object below = 140 { // object: 12 + 4*8 "streetAddress": "21 2nd Street", // key 16, value 16 "city" : "New York", // key 8, value 12 "state" : "NY", // key 8, value 4 "postalCode" : "10021" // key 12, value 8 }, // object total: 128 "phoneNumber": // key: 16, value array below = 172 [ // array: 12 + 2*4 + values below: 156 { // object 12 + 2*8 "type" : "home", // key 8, value 8 "number": "212 555-1234" // key 8, value 16 }, // object total: 68 { // object 12 + 2*8 "type" : "fax", // key 8, value 8 "number": "646 555-4567" // key 8, value 16 } // object total: 68 ] // array total: 156 } // great total: 412 bytes The uncompressed text file used roughly 500 bytes, so in this case we end up using about the same space as the text representation. Other measurements have shown a slightly bigger binary size than a compact text representation where all possible whitespace was stripped out. 20349 -
qbinaryjsonarray.cpp 2821 -
qbinaryjsonarray_p.h 1426 -
qbinaryjsonobject.cpp 3539 -
qbinaryjsonobject_p.h 1454 -
qbinaryjsonvalue.cpp 2568 -
qbinaryjsonvalue_p.h 2716 -