tidwall / gjson

Get JSON values quickly - JSON parser for Go
MIT License
13.95k stars 841 forks source link

the accelerated function ParseBytes converts bytes to string #292

Closed 52funny closed 1 year ago

52funny commented 1 year ago

use unsafe to speed up the conversion of bytes to string

tidwall commented 1 year ago

Your solution is not safe because the Parse function returns a Result type that hangs onto a slice of the original string. The output Result.Raw will now be a string that is pointing to data in the original byte slice.

52funny commented 1 year ago

Thank you for your answer, it was my lack of consideration.