jq

package
v1.6.2 Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2020 License: Apache-2.0 Imports: 3 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

View Source
var JqDefaultCache = func() *JqCache {
	if jqDefaultCacheInstance == nil {
		jqDefaultCacheInstance = NewJqCache()
	}
	return jqDefaultCacheInstance
}

Functions

func CgoCall

func CgoCall(f func())

CgoCall is used to run C code of a jq in a dedicated go-routine locked to OS thread.

Types

type Jq

type Jq struct {
	Cache   *JqCache
	LibPath string
}

High level API for libjq.

Jq has this options: - cache - library path

func NewJq

func NewJq() *Jq

func (*Jq) Program

func (jq *Jq) Program(program string) *JqProgram

func (*Jq) WithCache

func (jq *Jq) WithCache(cache *JqCache) *Jq

func (*Jq) WithLibPath

func (jq *Jq) WithLibPath(path string) *Jq

type JqCache

type JqCache struct {
	StateCache map[string]*libjq.JqState
	// contains filtered or unexported fields
}

func NewJqCache

func NewJqCache() *JqCache

func (*JqCache) Get

func (jc *JqCache) Get(key string) *libjq.JqState

func (*JqCache) Set

func (jc *JqCache) Set(key string, state *libjq.JqState)

func (*JqCache) Teardown

func (jc *JqCache) Teardown(key string)

func (*JqCache) TeardownAll

func (jc *JqCache) TeardownAll()

type JqProgram

type JqProgram struct {
	Jq          *Jq
	Program     string
	CacheLookup bool
}

func (*JqProgram) Cached

func (jqp *JqProgram) Cached() *JqProgram

Cached set cached flag so next call to Run will put compiled program to cache.

func (*JqProgram) Precompile

func (jqp *JqProgram) Precompile() (p *JqProgram, err error)

Precompile can be used to compile a program and store jq state in cache. Method returns error in case of syntax error.

func (*JqProgram) Run

func (jqp *JqProgram) Run(data string) (s string, e error)

Run actually runs a program over passed data. It compiles program if the program is not compiled yet.

func (*JqProgram) RunRaw

func (jqp *JqProgram) RunRaw(data string) (s string, e error)

RunRaw actually runs a program over passed data. It compiles program if the program is not compiled yet. Returns an unquoted string if filter result is a string.

Jump to

Keyboard shortcuts

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