msgpack-scala icon indicating copy to clipboard operation
msgpack-scala copied to clipboard

readArrayBegin in org.msgpack.template.builder.ScalaBuildContext#buildReadMethodBody

Open andypetrella opened this issue 11 years ago • 1 comments

It might not be an issue but part of my misunderstanding of the problem.

Let me explain it before I comment the title.

I'm trying to read into a class A which has 2 fields, let's say

class A {
  var a:String
  var b:String
}

I've written a serialization of such event in a file, that I'll try to read like this:

    val openStream: InputStream = new URL("file:///temp/test").openStream()
    var events = ScalaMessagePack.read[Event](openStream)

    println(events)

And here is what I got:

Expected array, but got map value
org.msgpack.MessageTypeException: Expected array, but got map value
    at org.msgpack.unpacker.Accept.acceptMap(Accept.java:93)
    at org.msgpack.unpacker.MessagePackUnpacker.readOneWithoutStack(MessagePackUnpacker.java:132)
    at org.msgpack.unpacker.MessagePackUnpacker.readOne(MessagePackUnpacker.java:73)

This happen because the method referred in the title is always calling readArrayBegin at the start of the read. However, it look like the binary file I've written based on write is not writing an array but a map. However, if I readAsValue the file, it will work by resulting a MapValue...

Is there something I miss, or is it a bug (which I don't believe).

Thanks for you help

andypetrella avatar Feb 06 '14 16:02 andypetrella

MsgpackScala doesn't support FieldName-Value map type class mapping now. Only field aligned array mapping is supported.

takezoux2 avatar Aug 14 '14 14:08 takezoux2