accessor

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Apr 15, 2020 License: GPL-3.0 Imports: 5 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Accessor

type Accessor interface {
	Get(key string) (value interface{}, ok bool)
	GetString(key string) (value string, ok bool)
	GetStringArray(key string) (value []string, ok bool)
	GetInt(key string) (value int64, ok bool)
	GetFloat(key string) (value float64, ok bool)
	GetBool(key string) (value bool, ok bool)
	Exists(key string) bool

	Set(key string, value interface{}) error

	Type() string
}

Accessor provides an interface to supply the query matcher a method to retrieve values from an object.

type JSONAccessor

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

JSONAccessor is a json string with get functions.

func NewJSONAccessor

func NewJSONAccessor(json *string) *JSONAccessor

NewJSONAccessor adds the Accessor interface to a JSON string.

func (*JSONAccessor) Exists

func (ja *JSONAccessor) Exists(key string) bool

Exists returns the whether the given key exists.

func (*JSONAccessor) Get

func (ja *JSONAccessor) Get(key string) (value interface{}, ok bool)

Get returns the value found by the given json key and whether it could be successfully extracted.

func (*JSONAccessor) GetBool

func (ja *JSONAccessor) GetBool(key string) (value bool, ok bool)

GetBool returns the bool found by the given json key and whether it could be successfully extracted.

func (*JSONAccessor) GetFloat

func (ja *JSONAccessor) GetFloat(key string) (value float64, ok bool)

GetFloat returns the float found by the given json key and whether it could be successfully extracted.

func (*JSONAccessor) GetInt

func (ja *JSONAccessor) GetInt(key string) (value int64, ok bool)

GetInt returns the int found by the given json key and whether it could be successfully extracted.

func (*JSONAccessor) GetString

func (ja *JSONAccessor) GetString(key string) (value string, ok bool)

GetString returns the string found by the given json key and whether it could be successfully extracted.

func (*JSONAccessor) GetStringArray

func (ja *JSONAccessor) GetStringArray(key string) (value []string, ok bool)

GetStringArray returns the []string found by the given json key and whether it could be successfully extracted.

func (*JSONAccessor) Set

func (ja *JSONAccessor) Set(key string, value interface{}) error

Set sets the value identified by key.

func (*JSONAccessor) Type

func (ja *JSONAccessor) Type() string

Type returns the accessor type as a string.

type JSONBytesAccessor

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

JSONBytesAccessor is a json string with get functions.

func NewJSONBytesAccessor

func NewJSONBytesAccessor(json *[]byte) *JSONBytesAccessor

NewJSONBytesAccessor adds the Accessor interface to a JSON bytes string.

func (*JSONBytesAccessor) Exists

func (ja *JSONBytesAccessor) Exists(key string) bool

Exists returns the whether the given key exists.

func (*JSONBytesAccessor) Get

func (ja *JSONBytesAccessor) Get(key string) (value interface{}, ok bool)

Get returns the value found by the given json key and whether it could be successfully extracted.

func (*JSONBytesAccessor) GetBool

func (ja *JSONBytesAccessor) GetBool(key string) (value bool, ok bool)

GetBool returns the bool found by the given json key and whether it could be successfully extracted.

func (*JSONBytesAccessor) GetFloat

func (ja *JSONBytesAccessor) GetFloat(key string) (value float64, ok bool)

GetFloat returns the float found by the given json key and whether it could be successfully extracted.

func (*JSONBytesAccessor) GetInt

func (ja *JSONBytesAccessor) GetInt(key string) (value int64, ok bool)

GetInt returns the int found by the given json key and whether it could be successfully extracted.

func (*JSONBytesAccessor) GetString

func (ja *JSONBytesAccessor) GetString(key string) (value string, ok bool)

GetString returns the string found by the given json key and whether it could be successfully extracted.

func (*JSONBytesAccessor) GetStringArray

func (ja *JSONBytesAccessor) GetStringArray(key string) (value []string, ok bool)

GetStringArray returns the []string found by the given json key and whether it could be successfully extracted.

func (*JSONBytesAccessor) Set

func (ja *JSONBytesAccessor) Set(key string, value interface{}) error

Set sets the value identified by key.

func (*JSONBytesAccessor) Type

func (ja *JSONBytesAccessor) Type() string

Type returns the accessor type as a string.

type StructAccessor

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

StructAccessor is a json string with get functions.

func NewStructAccessor

func NewStructAccessor(object interface{}) *StructAccessor

NewStructAccessor adds the Accessor interface to a JSON string.

func (*StructAccessor) Exists

func (sa *StructAccessor) Exists(key string) bool

Exists returns the whether the given key exists.

func (*StructAccessor) Get

func (sa *StructAccessor) Get(key string) (value interface{}, ok bool)

Get returns the value found by the given json key and whether it could be successfully extracted.

func (*StructAccessor) GetBool

func (sa *StructAccessor) GetBool(key string) (value bool, ok bool)

GetBool returns the bool found by the given json key and whether it could be successfully extracted.

func (*StructAccessor) GetFloat

func (sa *StructAccessor) GetFloat(key string) (value float64, ok bool)

GetFloat returns the float found by the given json key and whether it could be successfully extracted.

func (*StructAccessor) GetInt

func (sa *StructAccessor) GetInt(key string) (value int64, ok bool)

GetInt returns the int found by the given json key and whether it could be successfully extracted.

func (*StructAccessor) GetString

func (sa *StructAccessor) GetString(key string) (value string, ok bool)

GetString returns the string found by the given json key and whether it could be successfully extracted.

func (*StructAccessor) GetStringArray

func (sa *StructAccessor) GetStringArray(key string) (value []string, ok bool)

GetStringArray returns the []string found by the given json key and whether it could be successfully extracted.

func (*StructAccessor) Set

func (sa *StructAccessor) Set(key string, value interface{}) error

Set sets the value identified by key.

func (*StructAccessor) Type

func (sa *StructAccessor) Type() string

Type returns the accessor type as a string.

Jump to

Keyboard shortcuts

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