ohler55 / ojg

Optimized JSON for Go
MIT License
857 stars 49 forks source link

Array indexes with last return reverse order #118

Closed lsytj0413 closed 1 year ago

lsytj0413 commented 1 year ago

Give this code:

    expr, err := jp.ParseString("$.vals[-3:]")
    if err != nil {
        panic(err)
    }

    result := expr.Get(map[string]interface{}{
        "vals": []int{0, 10, 20, 30, 40, 50},
    })
    fmt.Printf("result: %v\n", result)

the result is: [50 40 30],but it should be [30 40 50],evaluated at https://jsonpath.com/

image

version: v1.17.5

ohler55 commented 1 year ago

I'll get it fixed.

ohler55 commented 1 year ago

Did release v1.18.0 and later fix the issue?

ohler55 commented 1 year ago

No response, closing.

lsytj0413 commented 1 year ago

Did release v1.18.0 and later fix the issue?

Sorry for the late reply. I have test it on v1.18.5,this have been fixed.