jsonql

package
v0.0.0-...-448f349 Latest Latest
Warning

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

Go to latest
Published: Jun 28, 2020 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Element

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

Element - an item in the stack

type JSONQL

type JSONQL struct {
	Data          interface{}
	SelectedField []string
}

JSONQL - JSON Query Lang struct encapsulating the JSON data.

func NewQuery

func NewQuery(jsonObject interface{}) *JSONQL

NewQuery - creates a new &JSONQL from an array of interface{} or a map of [string]interface{}

func NewStringQuery

func NewStringQuery(jsonString string) (*JSONQL, error)

NewStringQuery - creates a new &JSONQL from raw JSON string

func (*JSONQL) Get

func (thisJSONQL *JSONQL) Get() (interface{}, error)

Get - queries against the JSON using the conditions specified in the where stirng.

func (*JSONQL) Select

func (thisJSONQL *JSONQL) Select(selectField []string) *JSONQL

Select - queries against the JSON using the conditions specified in the where stirng.

func (*JSONQL) Where

func (thisJSONQL *JSONQL) Where(where string) *JSONQL

Where - queries against the JSON using the conditions specified in the where stirng.

type Lifo

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

Lifo - last in first out stack

func (*Lifo) Len

func (s *Lifo) Len() int

Len - gets the length of the stack.

func (*Lifo) Peep

func (s *Lifo) Peep() (value interface{})

Peep - gets the last value in the stack without popping it out.

func (*Lifo) Pop

func (s *Lifo) Pop() (value interface{})

Pop - pops the last value out of the stack.

func (*Lifo) Print

func (s *Lifo) Print()

Print - shows what's in the stack.

func (*Lifo) Push

func (s *Lifo) Push(value interface{})

Push - pushes the value into the stack.

type Operator

type Operator struct {
	Precedence int
	Eval       func(symbolTable interface{}, left string, right string) (string, error)
}

Operator - encapsulates the Precedence and behavior logic of the operators.

type Parser

type Parser struct {
	Operators   map[string]*Operator
	SymbolTable interface{}
	// contains filtered or unexported fields
}

Parser - the main struct that contains operators, symbol table.

func (*Parser) Calculate

func (thisParser *Parser) Calculate(expression string) (string, error)

Calculate - gets the final result of the expression

func (*Parser) Evaluate

func (thisParser *Parser) Evaluate(ts *Lifo, postfix bool) (string, error)

Evaluate - evaluates the token stack until only one (as the final result) is left.

func (*Parser) Init

func (thisParser *Parser) Init()

Init - init inspects the Operators and learns how long the longest operator string is

func (*Parser) ParseRPN

func (thisParser *Parser) ParseRPN(tokens []string) (output *Lifo, err error)

ParseRPN - parses the RPN tokens

func (*Parser) Tokenize

func (thisParser *Parser) Tokenize(exp string) (tokens []string)

Tokenize - splits the expression into tokens.

type Stack

type Stack interface {
	Len() int
	Push(value interface{})
	Pop() (value interface{})
	Peep() (value interface{})
	Print()
}

Stack - a set of functions of the Stack

Jump to

Keyboard shortcuts

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