tidwall / sjson

Set JSON values very quickly in Go
MIT License
2.4k stars 165 forks source link

Set value type error! #52

Open xuzhuoxi opened 2 years ago

xuzhuoxi commented 2 years ago

sjson.Set(b.content, path, []uint8{1, 2, 3, 4}) value type "[]uint8" will change to "string"

tidwall commented 2 years ago

Go treats []byte and []uint8 as the same thing, and sjson treats []byte as a string.

https://github.com/tidwall/sjson/blob/master/sjson.go#L674-L676

There's no way, that I know of, to make a distinction between []byte and []uint8.