How to do binary serialisation?

80 views
Skip to first unread message

Srinivas JONNALAGADDA

unread,
Sep 9, 2015, 1:44:56 AM9/9/15
to Crystal
Hello,

        Suppose that I have an array of `UInt64`.  Further suppose that I perform some operations, and push several values into the array.  Now, I wish to serialise the values in binary format into a byte array.  How to do that?

        Naturally, I will later want to read that byte array (possibly from disk), and reconstruct the array in memory.  How to do that?  Thanks.

                                           -- 0|0

Jonne Haß

unread,
Sep 9, 2015, 5:37:26 AM9/9/15
to crysta...@googlegroups.com
There's a very early Marshal implementation in https://github.com/manastech/crystal/tree/marshalling, but not sure it can handle arrays yet.

Another avenue is to look into standardized binary message formats, like protobuf or msgpack for which I could find a Crystal implementation https://github.com/manastech/crystal/tree/marshalling

If that's nothing for you it should at least give you some ideas on how to devise and implement your own format.

Good luck,
Jonne
> --
> You received this message because you are subscribed to the Google
> Groups "Crystal" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to crystal-lang...@googlegroups.com
> <mailto:crystal-lang...@googlegroups.com>.
> To post to this group, send email to crysta...@googlegroups.com
> <mailto:crysta...@googlegroups.com>.
> Visit this group at http://groups.google.com/group/crystal-lang.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/crystal-lang/00abc16d-7006-4e9a-b555-cdee5efa1101%40googlegroups.com
> <https://groups.google.com/d/msgid/crystal-lang/00abc16d-7006-4e9a-b555-cdee5efa1101%40googlegroups.com?utm_medium=email&utm_source=footer>.
> For more options, visit https://groups.google.com/d/optout.

Jonne Haß

unread,
Sep 9, 2015, 5:38:05 AM9/9/15
to crysta...@googlegroups.com
Oh, forgot to copy the right link, sorry. Here it is: https://github.com/benoist/msgpack-crystal

Srinivas JONNALAGADDA

unread,
Sep 9, 2015, 7:44:09 AM9/9/15
to Crystal
        Thanks for the pointers, Jonne!  I see that Crystal's own (un)marshaller are coming up nicely.

        I do not think that I have a need for MsgPack right now, but shall make a note of that library too.

                                          -- 0|0
Reply all
Reply to author
Forward
0 new messages