Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // Separate nested key components with dots, e.g. "a.b.1.c.d" DotStyle = SeparatorStyle{Middle: "."} // Separate with path-like slashes, e.g. a/b/1/c/d PathStyle = SeparatorStyle{Middle: "/"} // Separate ala Rails, e.g. "a[b][c][1][d]" RailsStyle = SeparatorStyle{Before: "[", After: "]"} // Separate with underscores, e.g. "a_b_1_c_d" UnderscoreStyle = SeparatorStyle{Middle: "_"} )
Default styles
View Source
var NotValidInputError = errors.New("Not a valid input: map or slice")
Nested input must be a map or slice
Functions ¶
func Flatten ¶
func Flatten(nested map[string]interface{}, prefix string, style SeparatorStyle) (map[string]interface{}, error)
Flatten generates a flat map from a nested one. The original may include values of type map, slice and scalar, but not struct. Keys in the flat map will be a compound of descending map keys and slice iterations. The presentation of keys is set by style. A prefix is joined to each key.
Types ¶
type SeparatorStyle ¶
Click to show internal directories.
Click to hide internal directories.