Provide a GetString to get string type instead of byte slice
goodspark opened this issue · comments
goodspark commented
Could we get a function to just return the string
type instead of a byte slice?
I often just need the string
and noticed GetStringByte
is actually converting the underlying string to a byte.
func (v *Value) GetString(keys ...string) string {
v = v.Get(keys...)
if v == nil || v.Type() != TypeString {
return ""
}
return v.s
}
Aliaksandr Valialkin commented
This won't work, since v.s
is backed by byte slice, which changes on the next Parser.Parse
call. This means that the returned string contents will become garbage on the next Parser.Parse
call.