3 // Exclude returns a new Map with the keys in the specified []string
5 func (d Map) Exclude(exclude []string) Map {
9 var shouldInclude bool = true
10 for _, toExclude := range exclude {
24 // Copy creates a shallow copy of the Obj.
25 func (m Map) Copy() Map {
26 copied := make(map[string]interface{})
33 // Merge blends the specified map with a copy of this map and returns the result.
35 // Keys that appear in both will be selected from the specified map.
36 // This method requires that the wrapped object be a map[string]interface{}
37 func (m Map) Merge(merge Map) Map {
38 return m.Copy().MergeHere(merge)
41 // Merge blends the specified map with this map and returns the current map.
43 // Keys that appear in both will be selected from the specified map. The original map
44 // will be modified. This method requires that
45 // the wrapped object be a map[string]interface{}
46 func (m Map) MergeHere(merge Map) Map {
48 for k, v := range merge {
56 // Transform builds a new Obj giving the transformer a chance
57 // to change the keys and values as it goes. This method requires that
58 // the wrapped object be a map[string]interface{}
59 func (m Map) Transform(transformer func(key string, value interface{}) (string, interface{})) Map {
60 newMap := make(map[string]interface{})
62 modifiedKey, modifiedVal := transformer(k, v)
63 newMap[modifiedKey] = modifiedVal
68 // TransformKeys builds a new map using the specified key mapping.
70 // Unspecified keys will be unaltered.
71 // This method requires that the wrapped object be a map[string]interface{}
72 func (m Map) TransformKeys(mapping map[string]string) Map {
73 return m.Transform(func(key string, value interface{}) (string, interface{}) {
75 if newKey, ok := mapping[key]; ok {