render

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Sep 16, 2023 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	FileTypeYAML    = "yaml"
	FileTypeJSON    = "json"
	FileTypeUnknown = "unknown"
)

Variables

This section is empty.

Functions

func IsJSON

func IsJSON(content string) bool

IsJSON checks if the passed content of JSON.

func IsYAML

func IsYAML(content string) bool

IsYAML checks if the passed content of YAML.

func Operator

func Operator(query string) string

Operator identifies the operator passed in the query and matches to one from https://github.com/thedevsaddam/gojsonq/wiki/Queries#wherekey-op-val.

Types

type Object

type Object string

Object implements method that check for file content type.

func Marshal

func Marshal(data interface{}) (Object, error)

func (Object) CheckFileType

func (obj Object) CheckFileType(log *logrus.Logger) string

CheckFileType checks the file type of the content passed, it validates for YAML/JSON.

func (Object) String

func (obj Object) String() string

type Query

type Query struct {
	JSONQ *gojsonq.JSONQ
	// contains filtered or unexported fields
}

Query holds information of queries to be executed.

func SetQuery

func SetQuery(data interface{}, query string) (*Query, error)

SetQuery processes the data into a format FromString of gojsonq understands and return finally processed query.

func (*Query) ConstructQuery

func (q *Query) ConstructQuery(query string)

ConstructQuery process the query in string to a format that is understood by gojsonq.

func (*Query) GetQueryKey

func (q *Query) GetQueryKey() string

GetQueryKey returns the key used for query if set.

func (*Query) GetQueryObject

func (q *Query) GetQueryObject() string

GetQueryObject returns the object used for query if set.

func (*Query) GetQueryOperator

func (q *Query) GetQueryOperator() string

GetQueryOperator returns the operator used for query if exists.

func (*Query) GetQueryType

func (q *Query) GetQueryType() string

GetQueryType returns the type of query set.

func (*Query) GetQueryValue

func (q *Query) GetQueryValue() string

GetQueryValue returns the value used for query if set.

func (*Query) Print

func (q *Query) Print() string

Print prints the Query object to string format, mostly used for debug message.

func (*Query) QueryGet

func (q *Query) QueryGet() interface{}

QueryGet returns response post the GET query.

func (*Query) QueryPluck

func (q *Query) QueryPluck() interface{}

QueryPluck returns response post the PLUCK query.

func (*Query) QuerySort

func (q *Query) QuerySort() interface{}

QuerySort returns response post the SORT query.

func (*Query) QueryWhere

func (q *Query) QueryWhere() interface{}

QueryWhere returns response post the WHERE query.

func (*Query) RunQuery

func (q *Query) RunQuery() interface{}

RunQuery identifies the query type based on the type set by ConstructQuery and return the result post applying the query.

type Renderer

type Renderer struct {
	YAML bool
	JSON bool
	// contains filtered or unexported fields
}

Renderer implements methods to render output in JSON/YAML format.

func GetRenderer

func GetRenderer(writer io.Writer, log *logrus.Logger, yaml, json bool) Renderer

GetRenderer returns the new instance of Renderer.

func (*Renderer) Render

func (r *Renderer) Render(value interface{}) error

Render renders the output based on the output format selection (toYAML, toJSON). If none is selected it prints as the source.

func (*Renderer) ToCSV added in v0.2.0

func (r *Renderer) ToCSV(fileName string) (*csv.Writer, error)

Jump to

Keyboard shortcuts

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