json

package
v1.18.1 Latest Latest
Warning

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

Go to latest
Published: Mar 26, 2023 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PathSeparator = '.'
	PathEscape    = '\\'
)
View Source
const AS = 57348
View Source
const AliasSpecifier = "AS"
View Source
const EOF = -1
View Source
const OBJECT_PATH = 57346
View Source
const PATH_IDENTIFIER = 57346
View Source
const PATH_INDEX = 57347

Variables

View Source
var Path = NewPathMap()
View Source
var Query = NewQueryMap()

Functions

func ConvertRecordValueToJsonStructure

func ConvertRecordValueToJsonStructure(pathes []PathExpression, row []value.Primary) (json.Structure, error)

func ConvertTableValueToJsonStructure

func ConvertTableValueToJsonStructure(ctx context.Context, fields []string, rows [][]value.Primary) (json.Structure, error)

func ConvertToArray

func ConvertToArray(array json.Array) []value.Primary

func ConvertToTableValue

func ConvertToTableValue(array json.Array) ([]string, [][]value.Primary, error)

func ConvertToValue

func ConvertToValue(structure json.Structure) value.Primary

func EscapeIdentifier

func EscapeIdentifier(s string) string

func Extract

func Extract(query QueryExpression, data json.Structure) (json.Structure, error)

func LoadArray

func LoadArray(queryString string, jsontext string) ([]value.Primary, error)

func LoadTable

func LoadTable(queryString string, jsontext string) ([]string, [][]value.Primary, json.EscapeType, error)

func LoadValue

func LoadValue(queryString string, jsontext string) (value.Primary, error)

func NewPathSyntaxError

func NewPathSyntaxError(message string, token PathToken) error

func NewQuerySyntaxError

func NewQuerySyntaxError(message string, token QueryToken) error

func ParseValueToStructure

func ParseValueToStructure(val value.Primary) json.Structure

Types

type ArrayItem

type ArrayItem struct {
	Index int
	Child QueryExpression
}

func (ArrayItem) FieldLabel

func (e ArrayItem) FieldLabel() string

type Element

type Element struct {
	Label string
	Child QueryExpression
}

func (Element) FieldLabel

func (e Element) FieldLabel() string

type FieldExpr

type FieldExpr struct {
	Element Element
	Alias   string
}

func (FieldExpr) FieldLabel

func (e FieldExpr) FieldLabel() string

type ObjectPath

type ObjectPath struct {
	Name  string
	Child PathExpression
}

type PathExpression

type PathExpression interface{}

func ParsePath

func ParsePath(src string) (PathExpression, error)

func ParsePathes

func ParsePathes(fields []string) ([]PathExpression, error)

type PathLexer

type PathLexer struct {
	PathScanner
	// contains filtered or unexported fields
}

func (*PathLexer) Error

func (l *PathLexer) Error(_ string)

func (*PathLexer) Lex

func (l *PathLexer) Lex(lval *jpSymType) int

type PathMap

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

func NewPathMap added in v1.9.3

func NewPathMap() PathMap

func (PathMap) Parse

func (pmap PathMap) Parse(s string) (PathExpression, error)

type PathScanner

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

func (*PathScanner) Init

func (s *PathScanner) Init(src string) *PathScanner

func (*PathScanner) Scan

func (s *PathScanner) Scan() PathToken

type PathSyntaxError

type PathSyntaxError struct {
	Column  int
	Message string
}

func (PathSyntaxError) Error

func (e PathSyntaxError) Error() string

type PathToken

type PathToken struct {
	Token   int
	Literal string
	Column  int
}

type QueryExpression

type QueryExpression interface{}

func ParseQuery

func ParseQuery(src string) (QueryExpression, error)

type QueryLexer

type QueryLexer struct {
	QueryScanner
	// contains filtered or unexported fields
}

func (*QueryLexer) Error

func (l *QueryLexer) Error(e string)

func (*QueryLexer) Lex

func (l *QueryLexer) Lex(lval *jqSymType) int

type QueryMap

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

func NewQueryMap added in v1.9.3

func NewQueryMap() QueryMap

func (QueryMap) Parse

func (qmap QueryMap) Parse(s string) (QueryExpression, error)

type QueryScanner

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

func (*QueryScanner) Init

func (s *QueryScanner) Init(src string) *QueryScanner

func (*QueryScanner) Scan

func (s *QueryScanner) Scan() (QueryToken, error)

type QuerySyntaxError

type QuerySyntaxError struct {
	Char    int
	Message string
}

func (QuerySyntaxError) Error

func (e QuerySyntaxError) Error() string

type QueryToken

type QueryToken struct {
	Token   int
	Literal string
	Column  int
}

type RowValueExpr

type RowValueExpr struct {
	Child QueryExpression
}

type TableExpr

type TableExpr struct {
	Fields []FieldExpr
}

Jump to

Keyboard shortcuts

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