json

package
v0.0.0-...-9c09587 Latest Latest
Warning

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

Go to latest
Published: Jun 15, 2020 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckType

func CheckType(r gjson.Result, t Type) bool

CheckType takes a gjson.Result and an internal type and returns true, if the JSON value satisfies the type

This function *must* be used whenever a gjson.Result has to be checked against an internal type and acts as a single source of truth.

Types

type Iterator

type Iterator interface {
	Next() bool
	Value() *PathElem
}

Iterator allows to traverse a tree data structure

func NewIterator

func NewIterator(data *gjson.Result) Iterator

NewIterator initializes an iterator to a JSON document taken as input

type PathElem

type PathElem struct {
	Path  []string
	Value *gjson.Result
	// contains filtered or unexported fields
}

PathElem is an element inside a JSON tree, identified by a JSON value and a path inside the overall JSON document

type Type

type Type int

Type represents a JSON type

const (
	// Null is a JSON null value and default value if a value is not set
	Null Type = iota
	// Number is JSON number
	Number
	// Bool is a JSON boolean
	Bool
	// String is a JSON string
	String
	// Object is a JSON object
	Object
	// Array is a JSON array
	Array
	// Any represents any JSON data type (including null) and is only used as a "all-matcher" for
	// the checkType function
	Any
)

func GetJSONType

func GetJSONType(r gjson.Result) Type

GetJSONType returns the type of a gjson.Result, mapping its gjson.Type to the internally used one

func (Type) String

func (t Type) String() string

Jump to

Keyboard shortcuts

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