The Lucene search library has something like this. Data is stored /retrieved via codecs. Most write binary data, but one codec actually writes out all data as text. It is, of course, too slow for production use, but it is great for figuring out what is going on under the covers.
https://blog.mikemccandless.com/2010/10/lucenes-simpletext-c...