jsonexpr

package
v0.24.5 Latest Latest
Warning

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

Go to latest
Published: Oct 31, 2025 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package jsonexpr provides JSON extractor expression parser.

Index

Constants

View Source
const (
	Index = iota + 1
	Key
)

Variables

This section is empty.

Functions

func Extract

func Extract(
	d *jx.Decoder,
	paths SelectorTree,
	extract func(logql.Label, string),
) error

Extract extracts values from given paths using extract callback.

Types

type Path

type Path []Selector

Path is a list of selectors.

func Parse

func Parse(input string) (sel Path, _ error)

Parse parses selector expression.

type Selector

type Selector struct {
	Type  SelectorType
	Index int
	Key   string
}

Selector is a JSON field/element selector.

func IndexSel

func IndexSel(i int) Selector

IndexSel creates new index Selector.

func KeySel

func KeySel(k string) Selector

KeySel creates new key Selector.

type SelectorTree added in v0.20.0

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

SelectorTree is a simple prefix tree of selectors. Efficient for matching multiple JSON paths.

func MakeSelectorTree added in v0.20.0

func MakeSelectorTree(paths map[logql.Label]Path) SelectorTree

MakeSelectorTree creates a new SelectorTree from the given paths.

func (SelectorTree) IsEmpty added in v0.20.0

func (p SelectorTree) IsEmpty() bool

IsEmpty returns true if the tree is empty.

type SelectorType

type SelectorType int

SelectorType is a Selector type.

Jump to

Keyboard shortcuts

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