jsonpick

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2026 License: Apache-2.0 Imports: 4 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package jsonpick keeps selected fields of a JSON value (SPEC M6 design note: response field filtering). Paths are a JSONPath subset: dot-separated keys, each optionally followed by [*]; arrays are mapped over automatically, so "items.title" and "items[*].title" are the same. It is pure: no I/O.

Index

Constants

View Source
const (
	MaxPaths   = 32
	MaxPathLen = 256
)

Limits on a field list.

Variables

This section is empty.

Functions

func Check

func Check(path string) error

Check validates one path.

Types

type Picker

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

Picker keeps the fields it was parsed from. A nil *Picker keeps everything.

func Parse

func Parse(paths []string) (*Picker, error)

Parse checks paths and builds a Picker. No paths means no filtering (a nil Picker).

func (*Picker) Apply

func (p *Picker) Apply(v any) any

Apply returns a copy of v with only the selected parts. Arrays are mapped over; scalars at a path that goes deeper are dropped.

func (*Picker) Paths

func (p *Picker) Paths() []string

Paths are the fields the Picker keeps.

Jump to

Keyboard shortcuts

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