jsonq

package
v0.36.0 Latest Latest
Warning

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

Go to latest
Published: Jun 23, 2026 License: AGPL-3.0 Imports: 3 Imported by: 13

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Query

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

Query is a JSON query interface

func New

func New(content string) *Query

New creates a new Query object based on given input as a JSON

func (*Query) ArrayFieldStrings added in v0.34.0

func (q *Query) ArrayFieldStrings(selector string, field string) []string

ArrayFieldStrings iterates the JSON array at selector and extracts the named field from each object element, returning the values as a string slice. Returns nil if the selector doesn't exist or the value is not an array.

func (*Query) ArrayLength added in v0.9.0

func (q *Query) ArrayLength() int

ArrayLength returns number of elements in the array

func (*Query) Contains

func (q *Query) Contains(selector string) bool

Contains returns true if the json object has the key

func (*Query) Int32 added in v0.10.0

func (q *Query) Int32(selector string) int

Int32 returns a integer value from the json object based on its selector

func (*Query) IsArray added in v0.9.0

func (q *Query) IsArray() bool

IsArray returns true if the json object is an array

func (*Query) Raw added in v0.34.0

func (q *Query) Raw(selector string) []byte

Raw returns the raw JSON bytes at the given dot-notation selector, or nil if not found.

func (*Query) String

func (q *Query) String(selector string) string

String returns a string value from the json object based on its selector

func (*Query) Strings added in v0.34.0

func (q *Query) Strings(selector string) []string

Strings returns a slice of strings at the given selector. If the value is a JSON array of strings, each element is returned. If the value is a single string, a one-element slice is returned. Returns nil if the selector doesn't exist or the value is not a string/array.

Jump to

Keyboard shortcuts

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