kotlinx.serialization icon indicating copy to clipboard operation
kotlinx.serialization copied to clipboard

Add parameters startIndex and endIndex to BinaryFormat.decodeFromByteArray

Open jfontsaballs opened this issue 4 months ago • 1 comments

What is your use-case and why do you need this feature?

I need to deserialize an object received from websockets as a byte array (the ktor client library stores received data as a ByteArray), but in the same message I need to pass additional information that is not to be deserialized. I want to avoid creating copies of the array for performance reasons, but with the current implementation I can not tell it to only use part of the array.

Describe the solution you'd like

Add parameters startIndex and endIndex to BinaryFormat.decodeFromByteArray. These parameters should have default parameters 0 and bytes.size. This is similar to how decodeToString is implemented.

jfontsaballs avatar Aug 17 '25 21:08 jfontsaballs

Related to #3065

jfontsaballs avatar Aug 17 '25 21:08 jfontsaballs