jsonx

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Jul 24, 2022 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package jsonx implements functions to get JSON property values by their path.

Index

Constants

This section is empty.

Variables

View Source
var (

	// ErrFieldNotFound is thrown when a JSON path is invalid.
	ErrFieldNotFound = errors.New("could not find a field using provided json path")
)

Functions

func Reach

func Reach(path string, data any) (any, error)

Reach returns the field with the given path from the given json data Example:

data := map[string]any{"address": map[string]any{"street": "somewhere"}}
Reach("address.street", data)
will return "somewhere"

For arrays, use the notation "field[index]" to get a specific index

Types

This section is empty.

Jump to

Keyboard shortcuts

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