maputil

package module
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Jun 15, 2021 License: MIT Imports: 1 Imported by: 0

README

maputil

A go util package to assist working with JSON that has been unmarshaled into map[string]interface{} and []interface{} types.

License: MIT

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Key added in v1.2.0

type Key struct {
	// contains filtered or unexported fields
}

Key represents either the index of an array (int) or the key in a map (string).

func (Key) Array added in v1.2.0

func (k Key) Array() int

func (Key) IsArray added in v1.2.0

func (k Key) IsArray() bool

func (Key) IsMap added in v1.2.0

func (k Key) IsMap() bool

func (Key) Map added in v1.2.0

func (k Key) Map() string

type MapTraverser

type MapTraverser struct {
	// contains filtered or unexported fields
}

func NewMapTraverser

func NewMapTraverser(m map[string]interface{}) MapTraverser

func (MapTraverser) Child

func (t MapTraverser) Child(keys ...string) MapTraverser

func (MapTraverser) Delete

func (t MapTraverser) Delete(key string) bool

func (MapTraverser) FindAllWithKey

func (t MapTraverser) FindAllWithKey(key string) MapTraversers

func (MapTraverser) Set

func (t MapTraverser) Set(key string, i interface{}) bool

func (MapTraverser) SetAll added in v1.2.0

func (t MapTraverser) SetAll(fn SetFunc) int

SetAll traverses all []interface{} and map[string]interface{} types and calls the fn (SetFunc) for each key/value pair. If the SetFunc for a given key/value pair returns bool(true) as its 2nd return value, then said value will be updated to whatever SetFunc returned as the interface{}.

func (MapTraverser) Value

func (t MapTraverser) Value(key string, i interface{}) (interface{}, bool)

type MapTraversers

type MapTraversers []MapTraverser

type SetFunc added in v1.2.0

type SetFunc func(k Key, value interface{}) (interface{}, bool)

Jump to

Keyboard shortcuts

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