tools

package
v0.0.0-...-405b8c4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 9, 2015 License: MIT Imports: 4 Imported by: 0

README

tools

-- import "github.com/zgiber/tools/flatten"

Usage

func Flatten
func Flatten(src interface{}, prefix, separator string) (map[string]interface{}, error)

Flatten takes a source, prefix and separator, and produces a flat map[string]interface{} as a result, using prefix and separator for creating the keys in it. The src can be of type []interface{}, map[string]interface{} or valid JSON encoded string and []byte. If the source has bigger than 1 depth, the separator is used to produce keys in the result. If the source contains a conflicting key, it will be prefixed (again) in the result If the source is a slice, the result will have the index of the item as the key, as a string type.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Flatten

func Flatten(src interface{}, prefix, separator string) (map[string]interface{}, error)

Flatten takes a source, prefix and separator, and produces a flat map[string]interface{} from the source as a result, using prefix for the keys in the result. The src can be of type []interface{}, map[string]interface{} or valid JSON encoded string and []byte. If the source has bigger than 1 depth, the separator is used to produce keys in the result. If the source contains a conflicting key, it will be prefixed (again) in the result If the source is a slice, the result will have the index of the item as the key, as a string type.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL