Skip to content
/ gmap Public

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

License

Notifications You must be signed in to change notification settings

kkHAIKE/gmap

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

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

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages