json

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Oct 16, 2018 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	BeginArray     = '['
	BeginObject    = '{'
	EndArray       = ']'
	EndObject      = '}'
	NameSeparator  = ':'
	ValueSeparator = ','
	QuotationMark  = '"'
	EscapeMark     = '\\'
)
View Source
const (
	FalseValue = "false"
	TrueValue  = "true"
	NullValue  = "null"
)
View Source
const (
	PathSeparator = '.'
	PathEscape    = '\\'
)
View Source
const AS = 57348
View Source
const AliasSpecifier = "AS"
View Source
const BOOLEAN = 57348
View Source
const EOF = -1
View Source
const IndentSpaces = 2
View Source
const NULL = 57349
View Source
const NUMBER = 57346
View Source
const OBJECT_PATH = 57346
View Source
const PATH_IDENTIFIER = 57346
View Source
const PATH_INDEX = 57347
View Source
const STRING = 57347

Variables

View Source
var Path = PathMap{}
View Source
var Query = QueryMap{}
View Source
var WhiteSpaces = []rune{
	32,
	9,
	10,
	13,
}

Functions

func ConvertToArray

func ConvertToArray(array Array) []value.Primary

func ConvertToTableValue

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

func ConvertToValue

func ConvertToValue(structure Structure) value.Primary

func EncodeRune

func EncodeRune(r rune) []byte

func Escape

func Escape(s string) string

func EscapeAll

func EscapeAll(s string) string

func EscapeIdentifier

func EscapeIdentifier(s string) string

func EscapeWithHexDigits

func EscapeWithHexDigits(s string) string

func LoadArray

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

func LoadTable

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

func LoadValue

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

func NewPathSyntaxError

func NewPathSyntaxError(message string, token PathToken) error

func NewQuerySyntaxError

func NewQuerySyntaxError(message string, token QueryToken) error

func NewSyntaxError

func NewSyntaxError(message string, token Token) error

func Quote

func Quote(s string) string

func Unescape

func Unescape(s string) string

Types

type Array

type Array []Structure

func (Array) String

func (ar Array) String() string

type ArrayItem

type ArrayItem struct {
	Index int
	Child QueryExpression
}

func (ArrayItem) FieldLabel

func (e ArrayItem) FieldLabel() string

type Boolean

type Boolean bool

func (Boolean) String

func (b Boolean) String() string

type Decoder

type Decoder struct{}

func NewDecoder

func NewDecoder() *Decoder

func (Decoder) Decode

func (d Decoder) Decode(src string) (Structure, error)

type Element

type Element struct {
	Label string
	Child QueryExpression
}

func (Element) FieldLabel

func (e Element) FieldLabel() string

type Encoder

type Encoder struct {
	EscapeType  EscapeType
	PrettyPrint bool
	LineBreak   cmd.LineBreak
	// contains filtered or unexported fields
}

func NewEncoder

func NewEncoder() *Encoder

func (*Encoder) Encode

func (e *Encoder) Encode(structure Structure, useStyle bool) string

type EscapeType

type EscapeType int
const (
	Backslash        EscapeType = 0
	HexDigits        EscapeType = 1
	AllWithHexDigits EscapeType = 2
)

type FieldExpr

type FieldExpr struct {
	Element Element
	Alias   string
}

func (FieldExpr) FieldLabel

func (e FieldExpr) FieldLabel() string

type Lexer

type Lexer struct {
	Scanner
	// contains filtered or unexported fields
}

func (*Lexer) Error

func (l *Lexer) Error(e string)

func (*Lexer) Lex

func (l *Lexer) Lex(lval *yySymType) int

type Null

type Null struct{}

func (Null) String

func (n Null) String() string

type Number

type Number float64

func (Number) String

func (n Number) String() string

type Object

type Object struct {
	Members []ObjectMember
}

func NewObject

func NewObject(capacity int) Object

func (*Object) Add

func (obj *Object) Add(key string, val Structure)

func (*Object) Exists

func (obj *Object) Exists(key string) bool

func (*Object) Len

func (obj *Object) Len() int

func (Object) String

func (obj Object) String() string

func (*Object) Update

func (obj *Object) Update(key string, val Structure)

func (*Object) Value

func (obj *Object) Value(key string) Structure

type ObjectMember

type ObjectMember struct {
	Key   string
	Value Structure
}

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(e string)

func (*PathLexer) Lex

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

type PathMap

type PathMap map[string]PathExpression

func (PathMap) Parse

func (m 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 map[string]QueryExpression

func (QueryMap) Parse

func (m 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 Scanner

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

func (*Scanner) Init

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

func (*Scanner) Scan

func (s *Scanner) Scan() (Token, error)

type String

type String string

func (String) String

func (s String) String() string

type Structure

type Structure interface {
	String() string
}

func ConvertRecordValueToJsonStructure

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

func ConvertTableValueToJsonStructure

func ConvertTableValueToJsonStructure(fields []string, rows [][]value.Primary) (Structure, error)

func Extract

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

func ParseJson

func ParseJson(src string) (Structure, error)

func ParseValueToStructure

func ParseValueToStructure(val value.Primary) Structure

type SyntaxError

type SyntaxError struct {
	Line    int
	Column  int
	Message string
}

func (SyntaxError) Error

func (e SyntaxError) Error() string

type TableExpr

type TableExpr struct {
	Fields []FieldExpr
}

type Token

type Token struct {
	Token   int
	Literal string
	Line    int
	Column  int
}

Jump to

Keyboard shortcuts

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