There's a bunch of simplistic JSON parsers. I felt the need to write something similar for protobuf, so here's https://github.com/pkhuong/ppb

The basic idea is you predeclare all the fields you're interested in (including catch-all fields, as an option), prescan to gather stats like number of occurrence and total number of bytes, for each field (just enough to preallocate), then lex the same bytes again to get individual field info, in order.

GitHub - pkhuong/ppb: A non-allocating lexer for protocol buffers

A non-allocating lexer for protocol buffers. Contribute to pkhuong/ppb development by creating an account on GitHub.

GitHub
ppb/examples/picoscope.c at main · pkhuong/ppb

A non-allocating lexer for protocol buffers. Contribute to pkhuong/ppb development by creating an account on GitHub.

GitHub