MsgpackOptions
#struct MsgpackOptionsThe serialising options.
| Name | Type | Description |
|---|---|---|
use_str8 | bool = true | Use the str8 format for strings of 32 to 255 bytes; true by default. Set it false for very old readers that predate str8; those strings are then written as str16. |
import encoding.msgpack
import encoding.value
import encoding
import compress
func main throw:
mut v := value.NewValueObject()
value.ObjectSet(v, "id", value.ValueInt(7))
value.ObjectSet(v, "ok", value.ValueBool(true))
b := msgpack.Marshal(v)
println compress.BufLen(b), compress.BufToBase64(b)
back := try msgpack.Unmarshal(b)
println value.Equal(v, back), try back.field("id").int()
back2 := try msgpack.UnmarshalBytes(b.data, b.len)
println value.Equal(v, back2)
o := msgpack.MsgpackOptions {}
println compress.BufLen(msgpack.MarshalWith(v, o))
println encoding.HexEncode(compress.BufToStrUnsafe(msgpack.Marshal(value.ValueInt(5))))
end9 gqJpZAeib2vD true 7 true 9 05