This library can "flatten" and "unflatten" a hierarchy stored in a map[string]interface{}.
var m = map[string]interface{}{
"cpu.usage.0.user": map[string]interface{}{
"value": 2.3,
},
"cpu.usage.0.system": map[string]interface{}{
"value": 1.2,
},
}
tree := Unflatten(m, func(k string) []string { return strings.Split(k, ".") })
Thanks to Andrew Leap for rewriting this library and reminding me I need to use functions more in golang.
This code is Copyright (c) 2014 Mark Wolfe and licenced under the MIT licence. All rights not explicitly granted in the MIT license are reserved. See the included LICENSE.md file for more details.