Open Dentrax opened 4 years ago
Hey! Thanks for such a great JSON framework. I am happy to use!
We could provide a string field in *Value struct or a function that called like: parentKey or GetParentKey() string
string
*Value
parentKey
GetParentKey() string
Why we should need like these field or function is that actually is we can not get parent key's value from in *Value context.
func get(v *fastjson.Value) { var key string = v.GetParentKey() }
We must use Visit function in order to get key's value, which is not useful due to we must scan all of JSON's fields.
Visit
func get(v *fastjson.Value) { v.Visit(func(key []byte, v *fastjson.Value) { var key string = string(key) }) }
A few GetParentKey() examples:
GetParentKey()
{ "a": "foo", "b": "bar", "c": { "d": "baz", "e": 0 } }
nil
""
c
"c"
Thanks!
Hey @valyala, would you like any help with this issue? I am not making any promises but I'd be interested in looking into it, if you want.
Hey! Thanks for such a great JSON framework. I am happy to use!
We could provide a
string
field in*Value
struct or a function that called like:parentKey
orGetParentKey() string
Why we should need like these field or function is that actually is we can not get parent key's value from in
*Value
context.We must use
Visit
function in order to get key's value, which is not useful due to we must scan all of JSON's fields.A few
GetParentKey()
examples:nil
or""
.c
key, it returns"c"
Thanks!