Skip to content

Latest commit

 

History

History
30 lines (24 loc) · 819 Bytes

README.md

File metadata and controls

30 lines (24 loc) · 819 Bytes

gmap

GoDoc

This is a simple library that allows you to retrieve values from a map[string]interface{} or []interface{} using a path

It is similar to objx but simpler, and it includes support for case-insensitive keys.

usage

func Example() {
    data := []byte(`{
        "Foo": [{
            "Bar": {
                "hello.world": [1,2]
            }
        }]
    }`)

    var m map[string]interface{}
    _ = json.Unmarshal(data, &m)

    m2 := gmap.GetIgnoreCase(m, "foo.0.bar")
    fmt.Println(m2.MustMap().Get(`hello\.world.1`).MustInt())
    // Output: 2
}

link