francoispqt / gojay

high performance JSON encoder/decoder with stream API for Golang
MIT License
2.11k stars 113 forks source link

Return length of decoded input #160

Open bramp opened 3 years ago

bramp commented 3 years ago

Over websocket I receive a stream of objects. I know the byte length of each object, and I want to ensure (as a safety/sanity check) that DecodeObject(...) has fully read the input. I see the private function decodeObject(...) returns the length, but that's not made available to the user.

May I request that either 1) The API is changed to return the length 2) A public field/method is added to the Decoder type, that exposed the number of bytes read.