encodeObject

open override fun encodeObject(buffer: ByteBuffer, obj: Map<K, V>)

Writes the given object into the buffer.

Writes exactly the number of bytes objSize reports for the same object and advances the buffer's position by that much. The buffer needs that much room remaining.

The layout depends on the schema:

  • Primitives: Direct binary representation (int, long, double, etc.)

  • Strings: Length prefix (4 bytes) + UTF-8 encoded bytes

  • Booleans: Single byte (0x00 for false, 0x01 for true)

  • Arrays: Length prefix + encoded elements

  • Classes: Encoded fields in alphabetical order

Parameters

buffer

The buffer to write object data to

obj

The object to encode

Throws

if the buffer doesn't have enough space