gojsonq

package
v0.0.0-...-89edfd8 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 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 JSONQ

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

JSONQ describes a JSONQ type which contains all the state

func New

func New() *JSONQ

New a new instance of JSONQ

func (*JSONQ) Avg

func (j *JSONQ) Avg(property ...string) float64

Avg return average of values from array or from map using property

func (*JSONQ) Count

func (j *JSONQ) Count() (lnth int)

Count return the result total items count. Note: this could be a length of list/array/map

func (*JSONQ) Error

func (j *JSONQ) Error() error

Error return last error

func (*JSONQ) Errors

func (j *JSONQ) Errors() []error

Errors return list of errors

func (*JSONQ) File

func (j *JSONQ) File(filename string) *JSONQ

File read the json content from physical file

func (*JSONQ) Find

func (j *JSONQ) Find(path string) interface{}

Find return the result of a exact matching path

func (*JSONQ) First

func (j *JSONQ) First() interface{}

First return the first element of a list

func (*JSONQ) From

func (j *JSONQ) From(node string) *JSONQ

From seek the json content to provided node. e.g: "users.[0]" or "users.[0].name"

func (*JSONQ) Get

func (j *JSONQ) Get() interface{}

Get return the result

func (*JSONQ) GroupBy

func (j *JSONQ) GroupBy(property string) *JSONQ

GroupBy build a chunk of exact matched data in a group list using provided attribute/column/property

func (*JSONQ) JSONString

func (j *JSONQ) JSONString(json string) *JSONQ

JSONString read the json content from valid json string

func (*JSONQ) Last

func (j *JSONQ) Last() interface{}

Last return the last element of a list

func (*JSONQ) Macro

func (j *JSONQ) Macro(operator string, fn QueryFunc) *JSONQ

Macro add a new query func to the JSONQ

func (*JSONQ) Max

func (j *JSONQ) Max(property ...string) float64

Max return maximum value from array or from map using property

func (*JSONQ) Min

func (j *JSONQ) Min(property ...string) float64

Min return minimum value from array or from map using property

func (*JSONQ) Nth

func (j *JSONQ) Nth(index int) interface{}

Nth return the nth element of a list

func (*JSONQ) Only

func (j *JSONQ) Only(properties ...string) *JSONQ

Only collect properties from the list of object

func (*JSONQ) OrWhere

func (j *JSONQ) OrWhere(key, cond string, val interface{}) *JSONQ

OrWhere build an OrWhere clause, basically it's a group of AND clauses

func (*JSONQ) Pluck

func (j *JSONQ) Pluck(property string) interface{}

Pluck pluck a property from a list of objects and return a slice of interface{}

func (*JSONQ) Reader

func (j *JSONQ) Reader(r io.Reader) *JSONQ

Reader read the json content from io reader

func (*JSONQ) Reset

func (j *JSONQ) Reset() *JSONQ

Reset reset the current state of JSON instance and make a fresh object with the original json content

func (*JSONQ) Sort

func (j *JSONQ) Sort(order ...string) *JSONQ

Sort sort an array or an array // default ascending order. pass "desc" for descending order

func (*JSONQ) SortBy

func (j *JSONQ) SortBy(order ...string) *JSONQ

SortBy sort an array // default ascending order. pass "desc" for descending order

func (*JSONQ) String

func (j *JSONQ) String() string

func (*JSONQ) Sum

func (j *JSONQ) Sum(property ...string) float64

Sum return sum of values from array or from map using property

func (*JSONQ) Where

func (j *JSONQ) Where(key, cond string, val interface{}) *JSONQ

Where build a where clause. e.g: Where("name", "contains", "doe")

func (*JSONQ) WhereContains

func (j *JSONQ) WhereContains(key string, val interface{}) *JSONQ

WhereContains satisfy Where clause which contains provided value(string)

func (*JSONQ) WhereEndsWith

func (j *JSONQ) WhereEndsWith(key string, val interface{}) *JSONQ

WhereEndsWith satisfy Where clause which ends with provided value(string)

func (*JSONQ) WhereEqual

func (j *JSONQ) WhereEqual(key string, val interface{}) *JSONQ

WhereEqual is an alias of Where("key", "=", val)

func (*JSONQ) WhereIn

func (j *JSONQ) WhereIn(key string, val interface{}) *JSONQ

WhereIn is an alias for where('key', 'in', []string{"a", "b"})

func (*JSONQ) WhereNil

func (j *JSONQ) WhereNil(key string) *JSONQ

WhereNil is an alias of Where("key", "=", nil)

func (*JSONQ) WhereNotEqual

func (j *JSONQ) WhereNotEqual(key string, val interface{}) *JSONQ

WhereNotEqual is an alias of Where("key", "!=", val)

func (*JSONQ) WhereNotIn

func (j *JSONQ) WhereNotIn(key string, val interface{}) *JSONQ

WhereNotIn is an alias for where('key', 'notIn', []string{"a", "b"})

func (*JSONQ) WhereNotNil

func (j *JSONQ) WhereNotNil(key string) *JSONQ

WhereNotNil is an alias of Where("key", "!=", nil)

func (*JSONQ) WhereStartsWith

func (j *JSONQ) WhereStartsWith(key string, val interface{}) *JSONQ

WhereStartsWith satisfy Where clause which starts with provided value(string)

func (*JSONQ) WhereStrictContains

func (j *JSONQ) WhereStrictContains(key string, val interface{}) *JSONQ

WhereStrictContains satisfy Where clause which contains provided value(string). Note this will case sensitive

type QueryFunc

type QueryFunc func(x, y interface{}) bool

QueryFunc describes a conditional function which perform comparison

Jump to

Keyboard shortcuts

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