-
Notifications
You must be signed in to change notification settings - Fork 5
Open
Labels
enhancementNew feature or requestNew feature or request
Description
Describe the bug
I want to assert that a particular jsonpath evaluates to an empty array. This instead returns jsonpath.ErrorMemberNotExist.
To Reproduce
package main
import (
"encoding/json"
"fmt"
"reflect"
"github.com/AsaiYusuke/jsonpath"
)
func main() {
jsonPath, srcJSON := `$[?(@.id == 2)].name`, `[ { "id": 1, "name": "One" } ]`
var src interface{}
json.Unmarshal([]byte(srcJSON), &src)
output, err := jsonpath.Retrieve(jsonPath, src)
if err != nil {
fmt.Printf(`%v, %v`, reflect.TypeOf(err), err)
return
}
outputJSON, _ := json.Marshal(output)
fmt.Println(string(outputJSON))
}This returns: jsonpath.ErrorMemberNotExist, member did not exist (path=[?(@.id == 2)])
Expected behavior
I expected it to return an empty array/slice (e.g. any[]{}).
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request