MoshiPack
MoshiPack copied to clipboard
Examples for unsigned integers and nils
Hey,
I have some issues implementing my expected behavior.
1. Unsigned integers
I'd like to pack a number as uint8. How can I do that? Using byte
as a type doesn't seem to work.
2. Integer based keys
The example shows packing an object into MsgPack. I'd like to pack my own structure which looks like
{
someUInt8Key: someUInt8Value
}
or
{
someUInt8Key: [someUInt8Value, someOtherUInt8Value]
}
Can I achieve it with MoshiPack?
3. Packing nulls
Following the example, I modified it to have
data class MessagePackWebsitePlug(var compact: Byte? = null)
which packs to bytes [0x80]
which means that it's a map with length 0. Is there any way to pack nulls?
Let me know your thoughts :)
On nulls, I think you'll need to pass in a Moshi instance configured to serialize nulls.