Skip to content

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

@tjasko

Description

@tjasko

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions