francoispqt / gojay

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

Feature: DecodeArray, Add the ability to skip reading an array #159

Closed marcsantiago closed 7 months ago

marcsantiago commented 3 years ago

This allows the user to set a limit on the size of the array. Once the size is met, instead of continuing to read in the data eating cpu to move the cursor, we can fast iterate and move the cursor without decoding anymore data, see the test for an example on how it works. I came across this issue in production. It makes the cpu run very hot even when I limit the size because in order to move the cursor to throw away the data, you need to call a decode method.