Skip to content

Decoding does not work at all. #12

@jeffbdavenport

Description

@jeffbdavenport

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions