PaesslerAG / jsonpath

BSD 3-Clause "New" or "Revised" License
172 stars 37 forks source link

Examples don't work: "unexpected Ident while scanning operator" #6

Closed kabukky closed 5 years ago

kabukky commented 5 years ago

Hi,

trying out the Get example from the Godocs:

v := interface{}(nil)

json.Unmarshal([]byte(`{
        "welcome":{
                "message":["Good Morning", "Hello World!"]
            }
        }`), &v)

welcome, err := jsonpath.Get("$welcome.message[1]", v)
if err != nil {
    fmt.Println(err)
    os.Exit(1)
}

fmt.Println(welcome)

// Output
// Hello World!

Produces the following error:

parsing error: $welcome.message[1]      :1:2 - 1:9 unexpected Ident while scanning operator

Am I missing something?

/Edit: I'm jusing Go 1.11 btw. go version go1.11.2 darwin/amd64

Thanks

generikvault commented 5 years ago

It's my mistake. It should be "$welcome.message[1]" and it should be testet with the unit-test. I take a look.

kabukky commented 5 years ago

That works ("$.welcome.message[1]")! Thanks for your fast response 👍

generikvault commented 5 years ago

You're welcome. Thanks for revealing the example isssues 😄

I've fixed the examples.