Skip to content

This library will "unflatten" a map[string]interface{} where the keys represent some flattened structure.

License

Notifications You must be signed in to change notification settings

wolfeidau/unflatten

Repository files navigation

unflatten

This library can "flatten" and "unflatten" a hierarchy stored in a map[string]interface{}.

GitHub Actions status Go Report Card Documentation Coverage Status

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.

About

This library will "unflatten" a map[string]interface{} where the keys represent some flattened structure.

Resources

License

Stars

Watchers

Forks

Packages

No packages published