token

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Jan 22, 2022 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Tokenize

func Tokenize(query string) ([]string, error)

Tokenize converts a JSON Path query to a collection of parsable tokens

Types

type Options

type Options struct {
	// AllowMapReferenceByIndex allow maps to be referenced by index in any token.
	AllowMapReferenceByIndex bool
	// AllowStringReferenceByIndex allow string characters to be referenced by index in any token.
	AllowStringReferenceByIndex bool

	// AllowMapReferenceByIndex allow maps to be referenced by index in range tokens.
	AllowMapReferenceByIndexInRange bool
	// AllowStringReferenceByIndexInRange allow string characters to be referenced by index in range tokens.
	AllowStringReferenceByIndexInRange bool

	// AllowMapReferenceByIndexInUnion allow maps to be referenced by index in union tokens.
	AllowMapReferenceByIndexInUnion bool
	// AllowStringReferenceByIndexInUnion allow string characters to be referenced by index in union tokens.
	AllowStringReferenceByIndexInUnion bool

	// AllowMapReferenceByIndexInSubscript allow maps to be referenced by index in subscript tokens.
	AllowMapReferenceByIndexInSubscript bool
	// AllowStringReferenceByIndexInSubscript allow string characters to be referenced by index in subscript tokens.
	AllowStringReferenceByIndexInSubscript bool

	// FailUnionOnInvalidIdentifier force union tokens to fail on missing or invalid keys or invalid index.
	FailUnionOnInvalidIdentifier bool
}

Options represents optional functionality for the token parser that can be enabled or disabled.

The default will be for all optional functionality to be disabled.

type Token

type Token interface {
	Apply(root, current interface{}, next []Token) (interface{}, error)
	Type() string
	String() string
}

Token represents a component of a JSON Path query

func Parse

func Parse(tokenString string, options *Options) (Token, error)

Parse will parse a single token string and return an actionable token

Jump to

Keyboard shortcuts

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