lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

December 3, 2016 12:37 AM, "Sean Conner" <> wrote:

> I found the API itself interesting. When I wrote my CBOR module [1] I
> check the strings and if they pass as a UTF-8 string, I encode the string as
> TEXT; otherwise it gets encoded as BIN. It never occured to me to have a
> function set the default behavior, and I wonder how your method would work
> with a table of mixed strings and binary data (or is that even enough of a
> concern to conern yourself with? I don't know ... ).
> You do a similar thing with arrays, but it's rather terse about the
> 'with_hole' option---how does that work? Does the code in that case look
> for a field 'n' in the table? I just assume if a table has a length
> defined, it's encoded as an ARRAY; otherwise a MAP (and because of that, an
> empty table is encoded as a MAP).

You can probably do the same thing as with his MessagePack library:
use the function packer to encode anything.

for the details. Maybe a similar section should be added to the CBOR
module documentation as well.

Pierre Chapuis