SkillAgentSearch skills...

Unflatten

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

Install / Use

/learn @wolfeidau/Unflatten
About this skill

Quality Score

0/100

Supported Platforms

Universal

README

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.

View on GitHub
GitHub Stars21
CategoryDevelopment
Updated3y ago
Forks2

Languages

Go

Security Score

75/100

Audited on Jan 5, 2023

No findings