Skip to content

Serializing binary data #100

@romanskrabis

Description

@romanskrabis

Hi,

How do I serialize byte array as "bin" and not "str"? I thought this code with isBinary set to true should work, but it keeps returning "str" data anyway.

MessagePackObject obj = new MessagePackObject(new byte[] { 1, 2, 3 }, isBinary: true);
var serializer = SerializationContext.Default.GetSerializer();
byte[] serialized = serializer.PackSingleObject(obj);
Console.WriteLine("Serialized: {0}", BitConverter.ToString(serialized))

This is output:
Serialized: A3-01-02-03

While I would expect the following output:
Serialized: C4-03-01-02-03

Thanks, Roman

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions