Fq: Jq for Binary Formats
github.com
github.com
And the other things mentioned in the fq README:
https://github.com/HexFiend/HexFiend https://github.com/binspector/binspector
What's it good for?
There's a reason why all the cool companies invented their own serialization formats: Google's Protobuf, Facebook's Thrift, etc.. even when ASN.1 had been an international standard for years: It's too complicated.
Both Protobuf and Thrift evolved from RPC systems that possibly started out too simple for ASN.1, combined with above issue where good tools were probably commercial and expensive (FWIW, my experience also suggests that Thrift is shitty rpc system, compared even to Sun/ONC RPC, but maybe things changed)
I just wonder how on earth you want to be able to support all the binary formats out there. I mean, jq supports json, not all structured text data, like json, xml, csv, ini, ...
This is one of the seriously great ideas where I‘m thinking: How didn‘t anyone come up with that before?
Convert json <-> xml, csv, yaml, logfmt
So to support all formats, you write a binary <-> json converter.
But all that said i think you could use kaitai or something similar together with fq:s decode API if you want. I also have some ideas and plans on supporting writing deocders in jq, hopefully will get some time for that next year.
Another approach is to take the convert binary to object part of your code, output that as JSON on stdout and feed that into jq.
Basically, a binary front end + jq = fq
.frames[100].header.sample_rate
for the individual field and .frames[100].header|tobytes[:0x10]
for the first few bytes of the entire header structure?Or decode a binary slice as a particular format:
tobytes[0x234:0x325]|avc_sps.max_num_ref_frames # JSON for whole file
fq tovalue filegojq is also nice. I work with a lot of structured logs and wrapped jq with a little bit of format-understanding and output sugar to make looking at and analyzing such logs an enjoyable experience: https://github.com/jrockway/json-logs
Note that you can use jq to consume simple CSVs (and produce them) without anything else. There’s an entry in the cookbook wiki https://github.com/stedolan/jq/wiki/Cookbook#convert-a-csv-f... - I posted some usage examples a few months back https://news.ycombinator.com/item?id=27379423
In the future i hope to support writing decoders in jq and or support some declarative format like kaitai.
So it would require some sort of native (Go) plugins system, which I understand is about as bad as in Rust owing to there being no standard ABI (or plugins system for that matter).
therefore the way to have bespoke / internal formats would be to maintain an internal fork of the tool.
I'd make an improved one, one which is better. And I'd name it bbq.
If it were 'fk' sure, but the Q on the end makes me think of all the English words that come from French and end in 'ique', like technique. 'fq' looks like 'feek' to me.
however, i am a little disappointed that the jq syntax was chosen. jq has a very non-intuitive syntax. there are more intuitive query syntaxes out there. (linq or even basic sql come to mind.)
https://github.com/wader/fq/blob/master/doc/formats.md
They should probably make this a bit more prominent. It's an impressive list for a new project.
Also protobuf can contain embedded messages or even just the binary representation of a list of embedded messages.