|
|
|
|
|
by jerf
314 days ago
|
|
My rule of thumb that has been surprisingly robust over several uses of it is that if you gzip a JSON format you can expect it to shrink by a factor of about 15. That is not the hallmark of a space-efficient file format. Between repeated string keys and frequently repeated string values, that are often quite large due to being "human readable", it adds up fast. "I was also contemplating the mentioned formats for another project, but they are hardly usable when you need to store binary data, such as images, compressed data, or simply arbitrary data." One trick you can use is to prefix a file with some JSON or other readable value, then dump the binary afterwards. The JSON can have offsets into the binary as necessary for identifying things or labeling whether or not it is compressed or whatever. This often largely mitigates the inefficiency concerns because if you've got a big pile of binary data the JSON bloat by percent tends to be much smaller than the payload; if it isn't, then of course I don't recommend this. |
|
The GLB container (binary glTF) works almost exactly as you described, except there is a fixed size header before the JSON part.
https://registry.khronos.org/glTF/specs/2.0/glTF-2.0.html#bi...