@@ -222,7 +222,7 @@ public function json(mixed $data): self
222222
223223 // Usar pooling para datasets médios e grandes
224224 if ($ this ->shouldUseJsonPooling ($ sanitizedData )) {
225- $ encoded = $ this ->encodeWithPooling ($ sanitizedData );
225+ $ encoded = $ this ->encodeWithPooling ($ data , $ sanitizedData );
226226 } else {
227227 // Usar encoding tradicional para dados pequenos
228228 $ encoded = json_encode ($ sanitizedData , self ::JSON_ENCODE_FLAGS );
@@ -802,16 +802,16 @@ private function shouldUseJsonPooling(mixed $data): bool
802802 /**
803803 * Codifica JSON usando pooling para melhor performance
804804 */
805- private function encodeWithPooling (mixed $ data ): string
805+ private function encodeWithPooling (mixed $ data, mixed $ sanitizedData ): string
806806 {
807807 try {
808- return JsonBufferPool::encodeWithPool ($ data , self ::JSON_ENCODE_FLAGS );
808+ return JsonBufferPool::encodeWithPool ($ sanitizedData , self ::JSON_ENCODE_FLAGS );
809809 } catch (\Throwable $ e ) {
810810 // Fallback para encoding tradicional em caso de erro
811811 error_log ('JSON pooling failed, falling back to traditional encoding: ' . $ e ->getMessage ());
812812
813813 // Fallback to traditional encoding (handle JSON encoding failures internally)
814- $ encoded = json_encode ($ data , self ::JSON_ENCODE_FLAGS );
814+ $ encoded = json_encode ($ sanitizedData , self ::JSON_ENCODE_FLAGS );
815815 if ($ encoded === false ) {
816816 error_log ('JSON fallback encoding failed: ' . json_last_error_msg ());
817817 return '{} ' ;
0 commit comments