go-json-map: github.com/firewut/go-json-map Index | Files

package gjm

import "github.com/firewut/go-json-map"

Index

Package Files

gjm.go helpers.go

func AddProperty Uses

func AddProperty(original_data map[string]interface{}, path string, value interface{}, separator_arr ...string) (err error)

AddProperty adds a property to map. Returns an error if property already exists

err := AddProperty(document, "one.two.three[0]", "string value")
err := AddProperty(document, "one.two.three[0]", "string value", ".")
err := AddProperty(document, "one/two/three[0]", "string value", "/")

func DeleteProperty Uses

func DeleteProperty(original_data map[string]interface{}, path string, separator_arr ...string) (err error)

DeleteProperty removes a property from map

err := GetProperty(document, "one.two.three[0]")
err := GetProperty(document, "one.two.three[0]", ".")
err := GetProperty(document, "one/two/three[0]", "/")

func GetProperty Uses

func GetProperty(original_data map[string]interface{}, path string, separator_arr ...string) (path_parsed interface{}, err error)

GetProperty returns a property if it exist.

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

Property type is `interface{}`

func UpdateProperty Uses

func UpdateProperty(original_data map[string]interface{}, path string, value interface{}, separator_arr ...string) (err error)

UpdateProperty updates a property in a map. It will create or update existing property

err := UpdateProperty(document, "one.two.three[0]", "string value")
err := UpdateProperty(document, "one.two.three[0]", "string value", ".")
err := UpdateProperty(document, "one/two/three[0]", "string value", "/")

Package gjm imports 5 packages (graph). Updated 2017-01-23. Refresh now. Tools for package owners.