1. 21
  1.  

    1. 3

      the zero-byte can be omitted if the data is intended to be used only with languages which do not use null-terminated strings

      Seems like a bad idea to me. It’s too easy to have code that works until it doesn’t because the provided data stopped adding the extra null byte. If it’s really valuable to save that one byte, then it probably should be a different string TYPE_.

      Also this is simpler than messagepack, but not that much simpler. The TYPE_STRINGREF is a nice touch though, particularly for the classic “list of objects” JSON structure.

      1. 3

        https://github.com/rentzsch/lich/ is still my dream semi-binary, JSON-ish serialization.

        26{8<greeting>11<hello world>}
        

        You encode the block length in ASCII decimal, then a start tag ({ for obj, < for bytes, [ for array) then the specified length is read, then it checks for a closing byte pair (}, >, ]) to ensure non-corrupt delivery. Simple, easy to describe, reasonably efficient, unambiguous.

        1. 2

          At a first glance I thought it seems to have a lot of overhead but realistically, if the alternative is JSON, it’s neat and compact. Also it’s a good point that string interning can be an implementation detail and not visible to the user when deserializing.