json_utils

package
v1.5.2-rc4 Latest Latest
Warning

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

Go to latest
Published: Dec 7, 2021 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Action

type Action func(data *ActionData) (interface{}, error)

Action encapsulates the logic that must be performed for each JSON element

func OnlyForLeafsAndKeys added in v1.4.3

func OnlyForLeafsAndKeys(action Action) Action

OnlyForLeafsAndKeys is an action modifier - apply action only for leafs and map keys

type ActionData

type ActionData struct {
	Document interface{}
	Element  interface{}
	Path     string
}

ActionData represents data available for action on current element

type Key added in v1.4.3

type Key struct {
	Key string
}

Key type is needed for traversal to specify the key

type Traversal

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

Traversal is a type that encapsulates JSON traversal algorithm It traverses entire JSON structure applying some logic to its elements

func NewTraversal

func NewTraversal(document interface{}, action Action) *Traversal

NewTraversal creates JSON Traversal object

func (*Traversal) TraverseJSON

func (t *Traversal) TraverseJSON() (interface{}, error)

TraverseJSON performs a traverse of JSON document and applying action for each JSON element

Jump to

Keyboard shortcuts

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