stretchr / objx

Go package for dealing with maps, slices, JSON and other data.
MIT License
701 stars 75 forks source link

Unable to get value of nested []interface{} type #103

Closed tjasko closed 3 years ago

tjasko commented 3 years ago

Given the following JSON:

{"values":[["test"]]}

Attempting to get the value of "test" via the values[0][0] path fails.

Example program:

package main

import (
    "fmt"
    "github.com/stretchr/objx"
)

func main() {   
    d := objx.MustFromJSON(`{"values":[["test"]]}`)

    // Returns "[]interface {}{"test"}".
    fmt.Println(d.Get("values[0]").String())

    // Returns empty string.
    fmt.Println(d.Get("values[0][0]").String())
}

The expected result would be for d.Get("values[0][0]").String() to return test.