Skip to content

Byte array serialization #168

@rh0531

Description

@rh0531

Hello,

I'm trying to serialize byte array as bin not str by referring to #100
But I still got byte array { 0xa3, 0x01, 0x02, 0x03 }.
My expectation is { 0xc4, 0x03, 0x01, 0x02, 0x03 }

My code

MessagePackObject obj = new MessagePackObject(new byte[] { 1, 2, 3 }, isBinary: true);
var ctx = new SerializationContext(PackerCompatibilityOptions.None);
var serializer = ctx.GetSerializer<MessagePackObject>();
byte[] serialized = serializer.PackSingleObject(obj);

I found "str" is set on this if block.
https://github.com/msgpack/msgpack-cli/blob/master/src/MsgPack/MessagePackObject.Utilities.cs#L1063

My code is wrong? or is there any restriction?

Thanks,

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugDetected as bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions