ugorji / go

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

decode failed encoded by lua-cmsgpack in some cases #62

Closed friendwu closed 9 years ago

friendwu commented 9 years ago

hi, briefly describe the trouble I met below:

if I have two lua tables to represent map:

local t1 = {[1] = 1, [2] = 2, [3]= 3}
local t2 = {}

and I want to decode them to:

type T map[int]int

as lua-cmsgpack will encode them as an msgpack array(for t1, it's because the key indexes are continuous, for t2, it's because it's an empty table), the decode will fail in this two case.

Is there any way to get avoid of this?

ugorji commented 9 years ago

Sorry, I do not understand the bug report.

Can you attach a reproducer i.e. a file with a main method that I can run to reproduce the problem?

Thanks.

ugorji commented 9 years ago

I think I see what you are saying.

You want to decode from a msgpack array into a go map. That is not possible.

The issue is with lua-cmagpack, which encodes a map as an array. You should look for help there in ensuring that it encodes a lua map as amsgpack map.