context

package
v0.0.0-...-f79e951 Latest Latest
Warning

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

Go to latest
Published: Jun 19, 2024 License: MIT Imports: 5 Imported by: 1

Documentation

Index

Constants

View Source
const (
	Array  = 0
	Object = 1
)

Variables

View Source
var (
	ErrTypeAssertion      = errors.New("Type assertion")
	ErrTypeNotFound       = errors.New("Type not found")
	ErrIndexOutOfRange    = errors.New("Index out of range")
	ErrNoPropertyInObject = errors.New("No property in object")
)
View Source
var (
	ErrVariableNameBeginning    = errors.New("The variable name must begin with a letter or underscore")
	ErrVariableName             = errors.New("The variable name must contain only letters, numbers or underscores")
	ErrNoClosingSquareBracket   = errors.New("No closing square bracket")
	ErrWrongIndex               = errors.New("Wrong index")
	ErrUnknownCharacter         = errors.New("Unknown character")
	ErrVariableNameNotSpecified = errors.New("Variable name not specified")
)

Functions

func CheckPath

func CheckPath(path string) error

func NewErrIndexOutOfRange

func NewErrIndexOutOfRange(arrayName string, currentIndex int, from int, to int) error

func NewErrNoPropertyInObject

func NewErrNoPropertyInObject(obj string, property string) error

func NewErrTypeAssertion

func NewErrTypeAssertion(currentType string, expextedType string) error

Types

type Context

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

func NewContext

func NewContext() *Context

func NewContextFromJSON

func NewContextFromJSON(jsonData []byte) (*Context, error)

func (*Context) GetKyes

func (ctx *Context) GetKyes() []string

func (*Context) GetRawValue

func (ctx *Context) GetRawValue(key string) (any, bool)

func (*Context) GetValue

func (ctx *Context) GetValue(path string) (*Value, error)

func (*Context) SetValue

func (ctx *Context) SetValue(path string, value *any) error

func (*Context) ToJSON

func (ctx *Context) ToJSON() ([]byte, error)

type PathUnit

type PathUnit struct {
	Type    PathUnitType
	Propery string
	Index   int
	Subpath *PathUnitIterator
}

type PathUnitIterator

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

func NewPathUnitIterator

func NewPathUnitIterator(path string) *PathUnitIterator

func (*PathUnitIterator) HasNext

func (it *PathUnitIterator) HasNext() bool

func (*PathUnitIterator) Next

func (it *PathUnitIterator) Next() (*PathUnit, error)

type PathUnitType

type PathUnitType = int

type Value

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

func (*Value) GetRawValue

func (v *Value) GetRawValue() any

func (*Value) ToBool

func (v *Value) ToBool() (bool, error)

func (*Value) ToBytes

func (v *Value) ToBytes() ([]byte, error)

func (*Value) ToInt

func (v *Value) ToInt() (int, error)

func (*Value) ToInt64

func (v *Value) ToInt64() (int64, error)

func (*Value) ToString

func (v *Value) ToString() (string, error)

Jump to

Keyboard shortcuts

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