msgpack4z-core icon indicating copy to clipboard operation
msgpack4z-core copied to clipboard

Cannot handle optional values

Open ukayani opened this issue 5 years ago • 0 comments

Hi,

if I have the following case class:

case class Foo(a: String, b: Option[Int])

If i read a message pack encoded byte array which is equivalent to the following json (not encoded with msgpack4z):

{ "a": "test" }

I get a unpack error. Since the case class map codec looks for the presence of each key and fails if any key is not present.

It seems that the optionCodec expects the message pack encoded data to include the key regardless of whether there is a value for it or not.

Aside from writing my own case class codec, is there a way to handle unpacking such types?

ukayani avatar Jul 23 '18 20:07 ukayani