The only reason I can think of is to have a distinction between null values and undefined values in JSON (null -> nil, undefined -> error), but we don't always want to error out if the key is undefined, it'd be nice if we could configure this default behavior. I might be missing something here so please let me know if this is the case!
Hey,
Is there a reason why GVal defaults to returning nil if the expression references an undefined data key, but JsonPath errors out?
https://github.com/PaesslerAG/gval/blob/cd026a3dee26df39acddc2292229512c4fa68756/evaluable.go#L133 vs https://github.com/PaesslerAG/jsonpath/blob/3484786d6f977735413b0c538c298df9a9f7a5e2/selector.go#L92
As an example,
Results in
test
; however, if the expression is$.invalidData
then we error out:can not evaluate $.invalidData: unknown key invalidData
.BUT if we just use standard Gval expressions, i.e:
we get nil as a return value.
The only reason I can think of is to have a distinction between null values and undefined values in JSON (null -> nil, undefined -> error), but we don't always want to error out if the key is undefined, it'd be nice if we could configure this default behavior. I might be missing something here so please let me know if this is the case!