I'm probably missing something obvious but ... isn't this just (the moral equivalent of) ASN.1 (specifically BER[0])?
[0] https://en.wikipedia.org/wiki/X.690#BER_encoding