ugorji / go

idiomatic codec and rpc lib for msgpack, cbor, json, etc. msgpack.org[Go]
MIT License
1.86k stars 295 forks source link

compitable with msgpack of java's library #248

Closed ikenchina closed 6 years ago

ikenchina commented 6 years ago

hello, i encoded LoginU struct in Go and send to Java to decode, but java's message pack library(msgpack-0.6.12) reported bellow errors

    Array is end but readArrayEnd() is not called
    org.msgpack.MessageTypeException: Array is end but readArrayEnd() is not called
    at org.msgpack.unpacker.UnpackerStack.checkCount(UnpackerStack.java:61)

// java code:

public class LoginPack {
    @Message
    public static class LoginU {
        public int version;
        public String ip; 
        public String openid;
        public String access_token;
        public String test_uid;
    }
}

// go code

type LoginU struct {
    Version  int32
    Ip       string
    Openid   string
    Token    string
    Test_uid string
}

req := &WeiXinLoginU{}
buf := bytes.NewBuffer([]byte{})

var mh codec.MsgpackHandle
mh.StructToArray = true

encoder := codec.NewEncoder(buf, &mh)

encoder.Encode(req)
ugorji commented 6 years ago

@ikenchina

I'm sorry - but this is not a bug report in any sense. I need something I can reproduce, independent of java library.

Closing this. Please add notes and tag me and I will re-open if it is a bug report that I can dig into.