Documentation ¶
Overview ¶
Package jsong implements merging JSON objects.
Index ¶
- Variables
- func Array(v any) ([]any, bool)
- func Bool(v any) (bool, bool)
- func Compare(a, b any) int
- func CutKey(k string) (head any, tail string, leaf bool)
- func Delete(v any, path string) any
- func Extract(v any, path string) any
- func Float64(v any) (float64, bool)
- func Glob(v any, glob string, visitFn func(k string, v any))
- func GlobKey(v any, k string) []string
- func GlobValues(v any, k string) []any
- func IsLeaf(k string) bool
- func IsNull(v any) bool
- func JoinKey(base string, as ...any) string
- func Map(v any) any
- func Merge(dst, src any, dstPath, srcPath string) any
- func Must[T any](v T, err error) T
- func MustOk[T any](v T, ok bool) T
- func Object(v any) (map[string]any, bool)
- func Sort(vs any) any
- func SortByKey(vs any, key string) any
- func String(v any) (string, bool)
- func ValueOf(v any) any
- func Visit(v any, visitFn func(k string, v any) error) error
- type AddScalar
- type AnyReducer
- type ArrayMapper
- type ArrayReducer
- type ArrayRemapper
- type Decoder
- type Filter
- type GlobFilter
- type HashReducer
- type Ident
- type KeyMatcher
- type MapSeq
- type Mapper
- type Math2Mapper
- type MathMapper
- type MulScalar
- type NullReducer
- type NumericReducer
- type ObjectFieldFilter
- type ObjectMapper
- type ObjectReducer
- type ObjectRemapper
- type PartitionReducer
- type ReduceOp
- type Reducer
- type StringAgg
- type SumReducer
- type TrueCounter
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrSkip = errors.New("skip") ErrStop = errors.New("stop") )
Functions ¶
func Extract ¶
Extract the path from the value v or return nil if not present.
JSON paths are field or array indices joined by the dot character. The empty path returns the input value processed by ValueOf.
func GlobValues ¶
func JoinKey ¶
JoinKey appends the key args to the base.
Args should be either string or int64 or else JoinKey panics.
func Merge ¶
Merge the field of the JSON object data with the MergeOptions. It returns the resulting JSON data or any merge errors.
Types ¶
type AnyReducer ¶
type AnyReducer struct{ V any }
func (*AnyReducer) Add ¶
func (a *AnyReducer) Add(v any)
func (*AnyReducer) Value ¶
func (a *AnyReducer) Value() any
type ArrayMapper ¶
type ArrayMapper []Mapper
func (ArrayMapper) Map ¶
func (a ArrayMapper) Map(v any) any
type ArrayReducer ¶
type ArrayReducer []Reducer
func (ArrayReducer) Add ¶
func (a ArrayReducer) Add(x any)
func (ArrayReducer) Value ¶
func (a ArrayReducer) Value() any
type ArrayRemapper ¶
type ArrayRemapper []any
func (ArrayRemapper) Map ¶
func (a ArrayRemapper) Map(v any) any
type Decoder ¶
type Decoder struct {
// contains filtered or unexported fields
}
Decoder decodes JSONG from JSON.
type GlobFilter ¶
type GlobFilter struct {
Glob string
}
func (GlobFilter) Filter ¶
func (f GlobFilter) Filter(v any) bool
type HashReducer ¶
type HashReducer[T comparable] struct { New func() Reducer Hash func(any) T Partitions map[T]Reducer }
func (*HashReducer[T]) Add ¶
func (a *HashReducer[T]) Add(x any)
func (*HashReducer[T]) Value ¶
func (a *HashReducer[T]) Value() any
type KeyMatcher ¶
type KeyMatcher struct {
// contains filtered or unexported fields
}
func CompileKeyMatcher ¶
func CompileKeyMatcher(glob string) (*KeyMatcher, error)
func (*KeyMatcher) MatchKey ¶
func (m *KeyMatcher) MatchKey(k string) bool
type Math2Mapper ¶
func (Math2Mapper) Map ¶
func (a Math2Mapper) Map(v any) any
type MathMapper ¶
func (MathMapper) Map ¶
func (a MathMapper) Map(v any) any
type NullReducer ¶
type NullReducer struct{}
func (NullReducer) Add ¶
func (NullReducer) Add(any)
func (NullReducer) Value ¶
func (NullReducer) Value() any
type NumericReducer ¶
type NumericReducer struct { Op ReduceOp // contains filtered or unexported fields }
func (*NumericReducer) Add ¶
func (a *NumericReducer) Add(x any)
func (*NumericReducer) Value ¶
func (a *NumericReducer) Value() any
type ObjectFieldFilter ¶
type ObjectFieldFilter map[string]struct{}
ObjectFieldFilter returns a Filter which returns true only if the object has all the given fields.
func (ObjectFieldFilter) Filter ¶
func (f ObjectFieldFilter) Filter(v any) bool
type ObjectMapper ¶
func (ObjectMapper) Map ¶
func (a ObjectMapper) Map(v any) any
type ObjectReducer ¶
func (ObjectReducer) Add ¶
func (a ObjectReducer) Add(x any)
func (ObjectReducer) Value ¶
func (a ObjectReducer) Value() any
type ObjectRemapper ¶
func (ObjectRemapper) Map ¶
func (a ObjectRemapper) Map(v any) any
type PartitionReducer ¶
type PartitionReducer struct { New func() Reducer Key string // contains filtered or unexported fields }
func (*PartitionReducer) Add ¶
func (a *PartitionReducer) Add(x any)
func (*PartitionReducer) Reset ¶
func (a *PartitionReducer) Reset()
func (*PartitionReducer) Value ¶
func (a *PartitionReducer) Value() any
type SumReducer ¶
type SumReducer struct {
// contains filtered or unexported fields
}
func (*SumReducer) Add ¶
func (a *SumReducer) Add(x any)
func (*SumReducer) Value ¶
func (a *SumReducer) Value() any
type TrueCounter ¶
type TrueCounter struct {
// contains filtered or unexported fields
}
func (*TrueCounter) Add ¶
func (a *TrueCounter) Add(x any)
func (*TrueCounter) Value ¶
func (a *TrueCounter) Value() any
Source Files ¶
Click to show internal directories.
Click to hide internal directories.