I'm surprised to see so many comments here throwing up on the use of JSON. Have we really forgotten the Unix philosophy?
> Write programs to handle text streams, because that is a universal interface.
A lot of the data formats I've written recently have used JSON. Partly because of that aforementioned principal, but mostly because it's just easier and there are very little downsides. Almost every language has support for it so it's fairly universal, it's self documenting, it's easy to debug, easy to manipulate by hand, and easy to maintain.
Put more simply: I've implemented several data formats using custom binary and several data formats using JSON. JSON was easier and faster every single time.
My recommendation for data formats: just use JSON; unless you have a really good reason not to.
And I do mean really good reason. For example, many might think concerns about data size would be a reason not to use JSON. But go ahead and run some JSON through a compression algorithm some time. You'll be amazed. Compressed JSON is very competitive versus a custom binary format.
> several data formats using custom binary and several data formats using JSON
You may not realize it, but you've presented a false dichotomy here.
The alternate to JSON isn't "custom binary", it's standardized binary encodings that allow the same flexibility (or additional flexibility) compared to JSON. Some examples include cbor & msgpack.
>> Write programs to handle text streams, because that is a universal interface.
cryptsetup manipulates block devices. I don't think that line can or should really be applied to something that is fairly similar to a filesystem's on-disk format.
> Write programs to handle text streams, because that is a universal interface.
A lot of the data formats I've written recently have used JSON. Partly because of that aforementioned principal, but mostly because it's just easier and there are very little downsides. Almost every language has support for it so it's fairly universal, it's self documenting, it's easy to debug, easy to manipulate by hand, and easy to maintain.
Put more simply: I've implemented several data formats using custom binary and several data formats using JSON. JSON was easier and faster every single time.
My recommendation for data formats: just use JSON; unless you have a really good reason not to.
And I do mean really good reason. For example, many might think concerns about data size would be a reason not to use JSON. But go ahead and run some JSON through a compression algorithm some time. You'll be amazed. Compressed JSON is very competitive versus a custom binary format.