msgpack icon indicating copy to clipboard operation
msgpack copied to clipboard

Decoding does not work at all.

Open jeffbdavenport opened this issue 8 months ago • 0 comments

Even the most simple example:

        pub struct Map {
	        used_ids int
        }
        data := '{"used_ids": 1}'
	json_data := json.decode(Map, data)!
	println(json_data)

	// println("json: ${json_data}")
	encoded := msgpack.encode[Map](json_data)
	println("encoded: ${encoded}")

	decoded := msgpack.decode[Map](encoded)!
	println('Decoded data: ${decoded}')

result

unbreakable.Map{
    used_ids: 1
}
encoded: [129, 168, 117, 115, 101, 100, 95, 105, 100, 115, 210, 0, 0, 0, 1]
V panic: result not set (error decoding data: error decoding struct: error decoding struct field: used_ids;error decoding integer: invalid integer descriptor byte 117)
v hash: ead4d90
/tmp/v_1000/no_more_fables.01JTHHS476XN69YVQQTTQTK00P.tmp.c:3570: at _v_panic: Backtrace
/tmp/v_1000/no_more_fables.01JTHHS476XN69YVQQTTQTK00P.tmp.c:3533: by panic_result_not_set
/tmp/v_1000/no_more_fables.01JTHHS476XN69YVQQTTQTK00P.tmp.c:9183: by main__main
/tmp/v_1000/no_more_fables.01JTHHS476XN69YVQQTTQTK00P.tmp.c:9370: by main

Even your code examples do not decode

jeffbdavenport avatar May 06 '25 01:05 jeffbdavenport