Skip to content

firewut/go-json-map

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Build Status Godoc license

Go json map

Using this package you can [Get/Create/Update/Delete] your map's nested properties as easy as json.

For example:

document := map[string]interface{}{
	"one": map[string]interface{}{
		"two": map[string]interface{}{
			"three": []int{
				1, 2, 3,
			},
		},
		"four": map[string]interface{}{
			"five": []int{
				11, 22, 33,
			},
		},
	},
}

Get a property

property, err := GetProperty(document, "one.two.three[0]")
fmt.Println(property)
// property => 1

property, err = GetProperty(document, "one.two.three", ".")
fmt.Println(property)
// property => 1, 2, 3

Create

err := CreateProperty(document, "one.three", "third value")

Update

err := UpdateProperty(document, "one.two.three[0]", "updated value")
err := UpdateProperty(document, "one/two/three[4]", []int{1,2,3,4}, "/")

Delete

err := DeleteProperty(document, "one.four")
err := DeleteProperty(document, "one.two.three[3]")

About

Work with go maps using json like paths

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages