thedevsaddam / gojsonq

A simple Go package for querying over JSON, YAML, XML, and CSV data.
https://github.com/thedevsaddam/gojsonq/wiki
MIT License
2.19k stars 140 forks source link

Wrong results returned #85

Closed zfeng-idcf closed 3 years ago

zfeng-idcf commented 3 years ago
package main

import (
    "fmt"

    gojsonq "github.com/thedevsaddam/gojsonq/v2"
)

func main() {
    const jsonStr = `[{"a": 1, "b":2,"c":[1,2,3]}]`
    jq := gojsonq.New().JSONString(jsonStr)

    val := jq.WhereEqual("a", 1).Find("[0].c")
    fmt.Println("val: ", val) // should be [1,2,3], but the result is []

    val = jq.Reset().Find("[0].c")
    fmt.Println("val: ", val) // => [1,2,3]
}
zfeng-idcf commented 3 years ago

I misunderstood. Find and Where cannot be used together.