Unflatten
This library will "unflatten" a map[string]interface{} where the keys represent some flattened structure.
Install / Use
/learn @wolfeidau/UnflattenREADME
unflatten
This library can "flatten" and "unflatten" a hierarchy stored in a map[string]interface{}.
usage
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, ".") })
contributions
Thanks to Andrew Leap for rewriting this library and reminding me I need to use functions more in golang.
License
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.
