Documentation ¶
Overview ¶
Package jam. Decode yaml, json or toml. Encode yaml, json, toml, go syntax and go struct defs. Merge, Diff, Filter, Query things. Struct tags.
If structured data is scones and you are clotted cream, this is jam.
Index ¶
- func Diff(a, b interface{}) interface{}
- func Filter(v interface{}, path string) interface{}
- func FilterI(v interface{}, path string) interface{}
- func FilterIR(v interface{}, path string) interface{}
- func FilterR(v interface{}, path string) interface{}
- func Merge(a, b interface{}) interface{}
- func Query(v interface{}, s string) interface{}
- type Decoder
- type Encoder
- type Jam
- func (j *Jam) Diff(r interface{})
- func (j *Jam) Exec(dst io.Writer, src io.Reader) error
- func (j *Jam) Filter(q string)
- func (j *Jam) FilterI(q string)
- func (j *Jam) FilterIR(q string)
- func (j *Jam) FilterR(q string)
- func (j *Jam) Merge(r interface{})
- func (j *Jam) Query(q string)
- func (j *Jam) Value() interface{}
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Diff ¶
func Diff(a, b interface{}) interface{}
Diff ouputs c that satisfies Merge(a, c) == b. Transpose of Merge.
func Filter ¶
func Filter(v interface{}, path string) interface{}
Filter filters a structure according to the path. Elements of v that do not match are removed. The path must match from the root of v.
func FilterI ¶
func FilterI(v interface{}, path string) interface{}
FilterI filters a structure according to the path. Inverted. Elements of v that match are removed. The path must match from the root of v.
func FilterIR ¶
func FilterIR(v interface{}, path string) interface{}
FilterIR filters a structure according to the path. Inverted and Recursive. Elements of v that match are removed. The path may match at any depth in v.
func FilterR ¶
func FilterR(v interface{}, path string) interface{}
FilterR filters a structure according to the path. Recursive. Elements of v that do not match are removed. The path may match at any depth in v.
Types ¶
type Decoder ¶
type Decoder struct {
// contains filtered or unexported fields
}
Decoder reads yaml, json, or toml from a reader, "jam" struct tags are evaluated as jmespath expressions.
type Encoder ¶
type Encoder struct {
// contains filtered or unexported fields
}
Encoder writes yaml, json, toml, go syntax, or go struct definition to a writer. The behaviour depends on the underlying function, which may be set using the AsYaml, AsJson, AsToml, AsGo, and AsStruct methods. The default is yaml.
func NewEncoder ¶
NewEncoder creates an Encoder set to encode as yaml.
func (*Encoder) AsStruct ¶
AsStruct creates a copy of this Encoder set to create go struct definitions.
type Jam ¶
type Jam struct {
// contains filtered or unexported fields
}
Jam accumulates operations on a data tree.