itchyny / gojq

Pure Go implementation of jq
MIT License
3.3k stars 119 forks source link

Unexpected results occur when passing based on pointer #233

Closed hktalent closed 11 months ago

hktalent commented 11 months ago

Unexpected results occur when passing based on pointer

if ps, err := gojq.Parse(path); nil == err {
        if data := ps.Run(source); nil != data {
            if o, ok := data.Next(); ok {
                return o
            }
        }
    }

now if source is &map[string]interface{}{} so: fmt.Sprintf("%v",o) like this:

%!v(PANIC=Error method: invalid type: reflect.Value (map[cve:map[CVE_data_meta:map[.......]]))

If I don't pass based on pointer, everything works fine

hktalent commented 11 months ago

fixed

if m1,ok:=source.(*map[string]interface{});ok{
        source = *m1
    }