by jerf · 1y ago · 0 comments
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...
The trick for the mix of JSON with binary is a good reminder. That's how the ASAR file archive format works. That could indeed be usable for what I was working on: a new file format for random seek indexes. Although the gztool index format seems to suffice for now.
2) Plain old sqlite seems like a good idea, for a format (and also widely supported). Fast indexes included
3) combining (1) and (2) is probably a good idea as well
4) there's also Parquet