functions

package
v0.1.18 Latest Latest
Warning

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

Go to latest
Published: Jul 30, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package functions provides the RFC 9535 §2.4 built-in function implementations for JSONPath filter expressions.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Builtins

func Builtins() []ast.Function

Builtins returns the five RFC 9535 §2.4 built-in function implementations.

Types

type CountFunc

type CountFunc struct{}

CountFunc implements the RFC 9535 §2.4.6 count() function. It returns the number of nodes in a node list argument.

func (CountFunc) Call

Call returns the number of nodes in the node list argument.

func (CountFunc) Name

func (CountFunc) Name() string

Name returns the RFC 9535 function name.

func (CountFunc) ParameterCount added in v0.1.17

func (CountFunc) ParameterCount() int

ParameterCount returns the fixed arity.

func (CountFunc) ParameterType added in v0.1.17

func (CountFunc) ParameterType(int) ast.FuncType

ParameterType returns the parameter type.

func (CountFunc) ResultType

func (CountFunc) ResultType() ast.FuncType

ResultType returns the function result type.

type LengthFunc

type LengthFunc struct{}

LengthFunc implements the RFC 9535 §2.4.4 length() function. It returns the number of Unicode scalar values in a string, array elements, or object members, and nil for other inputs.

func (LengthFunc) Call

Call returns the length of the argument:

  • string: number of Unicode scalar values
  • []any: number of elements
  • map[string]any: number of members
  • nil or other: nil

func (LengthFunc) Name

func (LengthFunc) Name() string

Name returns the RFC 9535 function name.

func (LengthFunc) ParameterCount added in v0.1.17

func (LengthFunc) ParameterCount() int

ParameterCount returns the fixed arity.

func (LengthFunc) ParameterType added in v0.1.17

func (LengthFunc) ParameterType(int) ast.FuncType

ParameterType returns the parameter type.

func (LengthFunc) ResultType

func (LengthFunc) ResultType() ast.FuncType

ResultType returns the function result type.

type MatchFunc

type MatchFunc struct{}

MatchFunc implements the RFC 9535 §2.4.7 match() function. It reports whether the string argument fully matches the regex pattern.

func (MatchFunc) Call

Call returns true if the string argument fully matches the regex pattern. Returns false if either argument is not a string or the regex is invalid.

func (MatchFunc) Name

func (MatchFunc) Name() string

Name returns the RFC 9535 function name.

func (MatchFunc) ParameterCount added in v0.1.17

func (MatchFunc) ParameterCount() int

ParameterCount returns the fixed arity.

func (MatchFunc) ParameterType added in v0.1.17

func (MatchFunc) ParameterType(int) ast.FuncType

ParameterType returns the parameter type.

func (MatchFunc) ResultType

func (MatchFunc) ResultType() ast.FuncType

ResultType returns the function result type.

type SearchFunc

type SearchFunc struct{}

SearchFunc implements the RFC 9535 §2.4.7 search() function. It reports whether the string argument contains a substring matching the regex pattern.

func (SearchFunc) Call

Call returns true if the string argument contains a match for the regex pattern. Returns false if either argument is not a string or the regex is invalid.

func (SearchFunc) Name

func (SearchFunc) Name() string

Name returns the RFC 9535 function name.

func (SearchFunc) ParameterCount added in v0.1.17

func (SearchFunc) ParameterCount() int

ParameterCount returns the fixed arity.

func (SearchFunc) ParameterType added in v0.1.17

func (SearchFunc) ParameterType(int) ast.FuncType

ParameterType returns the parameter type.

func (SearchFunc) ResultType

func (SearchFunc) ResultType() ast.FuncType

ResultType returns the function result type.

type ValueFunc

type ValueFunc struct{}

ValueFunc implements the RFC 9535 §2.4.8 value() function. It returns the value of a single-node list and nil for empty or multi-node lists.

func (ValueFunc) Call

Call returns the value of the single node in the node list, or nil if the list is empty or contains more than one node.

func (ValueFunc) Name

func (ValueFunc) Name() string

Name returns the RFC 9535 function name.

func (ValueFunc) ParameterCount added in v0.1.17

func (ValueFunc) ParameterCount() int

ParameterCount returns the fixed arity.

func (ValueFunc) ParameterType added in v0.1.17

func (ValueFunc) ParameterType(int) ast.FuncType

ParameterType returns the parameter type.

func (ValueFunc) ResultType

func (ValueFunc) ResultType() ast.FuncType

ResultType returns the function result type.

Jump to

Keyboard shortcuts

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