sonicx

package
v1.0.75 Latest Latest
Warning

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

Go to latest
Published: Mar 28, 2026 License: MIT Imports: 5 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Config = Default
View Source
var Default = sonic.Config{
	NoNullSliceOrMap:        true,
	NoValidateJSONMarshaler: true,
	NoValidateJSONSkip:      true,
	CompactMarshaler:        true,
	CopyString:              true,
}.Froze()
View Source
var Empty = &Wrap{ast.NewNull()}

Empty - empty sonic node

View Source
var StableSort = sonic.Config{
	NoNullSliceOrMap:        true,
	NoValidateJSONMarshaler: true,
	NoValidateJSONSkip:      true,
	CompactMarshaler:        true,
	CopyString:              true,
	SortMapKeys:             true,
}.Froze()

Functions

func ArrayToMap

func ArrayToMap[T comparable](node *Wrap, filter func(T) bool, extractor func(*Wrap) T) *orderedmap.OrderedMap[T, struct{}]

ArrayToMap returns an orderedmap.OrderedMap of the results that pass the filter from the sonic node array, projected using the extractor func

func ArrayToSlice

func ArrayToSlice[T any](node *Wrap, filter func(T) bool, extractor func(*Wrap) T) []T

ArrayToSlice returns a slice of the results that pass the filter from the sonic node array, projected using the extractor func

func WrapBool

func WrapBool(w *Wrap) bool

WrapBool extracts a boolean value from the Wrap

func WrapFloat64

func WrapFloat64(w *Wrap) float64

WrapFloat64 extracts a float64 value from the Wrap

func WrapInteger

func WrapInteger(w *Wrap) int

WrapInteger extracts an integer value from the Wrap

func WrapInteger64

func WrapInteger64(w *Wrap) int64

WrapInteger64 extracts an int64 value from the Wrap

func WrapRaw

func WrapRaw(w *Wrap) string

WrapRaw extracts the raw string from the Wrap

func WrapRefString

func WrapRefString(w *Wrap) string

WrapRefString extracts a string value from the Wrap (without copy)

func WrapString

func WrapString(w *Wrap) string

WrapString extracts a string value from the Wrap (with copy)

Types

type Wrap

type Wrap struct {
	ast.Node
}

func Get

func Get(src []byte, path ...any) (*Wrap, error)

Get returns a Wrap for the node using the specified path

func GetCopyFromString

func GetCopyFromString(src string, path ...any) (*Wrap, error)

GetCopyFromString returns a Wrap for the node using the specified path

func GetFromString

func GetFromString(src string, path ...any) (*Wrap, error)

GetFromString returns a Wrap for the node using the specified path

func GetWithOptions

func GetWithOptions(src []byte, opts ast.SearchOptions, path ...any) (*Wrap, error)

GetWithOptions returns a Wrap for the node using the specified path and options

func Of

func Of(node ast.Node) *Wrap

Of wraps a Wrap as a Wrap

func OfPtr

func OfPtr(node *ast.Node) *Wrap

OfPtr wraps a Wrap pointer as a Wrap, returning empty node if nil

func WrapGet

func WrapGet(w *Wrap, key string) *Wrap

WrapGet returns a Wrap for the specified key

func WrapGetByPath

func WrapGetByPath(w *Wrap, path ...any) *Wrap

WrapGetByPath returns a Wrap for the specified path

func WrapIndex

func WrapIndex(w *Wrap, i int) *Wrap

WrapIndex returns a Wrap for the specified index

func (*Wrap) Bool

func (w *Wrap) Bool() bool

Bool extracts a boolean value from the Wrap

func (*Wrap) Float64

func (w *Wrap) Float64() float64

Float64 extracts a float64 value from the Wrap

func (*Wrap) Get

func (w *Wrap) Get(key string) *Wrap

Get returns a Wrap for the specified key

func (*Wrap) GetByPath

func (w *Wrap) GetByPath(path ...any) *Wrap

GetByPath returns a Wrap for the specified path

func (*Wrap) Index

func (w *Wrap) Index(i int) *Wrap

Index returns a Wrap for the specified index

func (*Wrap) Integer

func (w *Wrap) Integer() int

Integer extracts an integer value from the Wrap

func (*Wrap) Integer64

func (w *Wrap) Integer64() int64

Integer64 extracts an int64 value from the Wrap

func (*Wrap) Raw

func (w *Wrap) Raw() string

Raw extracts the raw string from the Wrap

func (*Wrap) RefString

func (w *Wrap) RefString() string

RefString extracts a string value from the Wrap (without copy)

func (*Wrap) String

func (w *Wrap) String() string

String extracts a string value from the Wrap (with copy) Sonic already handles copy

Jump to

Keyboard shortcuts

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