kazaam.v3: gopkg.in/qntfy/kazaam.v3/transform Index | Files

package transform

import "gopkg.in/qntfy/kazaam.v3/transform"

Package transform package contains canonical implementations of Kazaam transforms.


Package Files

coalesce.go concat.go default.go delete.go extract.go pass.go shift.go timestamp.go util.go uuid.go


var (
    NonExistentPath = RequireError("Path does not exist")

func Coalesce Uses

func Coalesce(spec *Config, data []byte) ([]byte, error)

Coalesce checks multiple keys and returns the first matching key found in raw []byte.

func Concat Uses

func Concat(spec *Config, data []byte) ([]byte, error)

Concat combines any specified fields and literal strings into a single string value with raw []byte.

func Default Uses

func Default(spec *Config, data []byte) ([]byte, error)

Default sets specific value(s) in output json in raw []byte.

func Delete Uses

func Delete(spec *Config, data []byte) ([]byte, error)

Delete deletes keys in-place from the provided data if they exist keys are specified in an array under "keys" in the spec.

func Extract Uses

func Extract(spec *Config, data []byte) ([]byte, error)

Extract returns the specified path as the top-level object in raw []byte.

func HandleUnquotedStrings Uses

func HandleUnquotedStrings(value []byte, dt jsonparser.ValueType) []byte

jsonparser strips quotes from returned strings, this adds them back

func Pass Uses

func Pass(spec *Config, data []byte) ([]byte, error)

Pass performs no manipulation of the passed-in data. It is useful for testing/default behavior.

func Shift Uses

func Shift(spec *Config, data []byte) ([]byte, error)

Shift moves values from one provided json path to another in raw []byte.

func Timestamp Uses

func Timestamp(spec *Config, data []byte) ([]byte, error)

Timestamp parses and formats timestamp strings using the golang syntax

func UUID Uses

func UUID(spec *Config, data []byte) ([]byte, error)

UUID tries to generate a UUID based on spec components

type Config Uses

type Config struct {
    Spec         *map[string]interface{} `json:"spec"`
    Require      bool                    `json:"require,omitempty"`
    InPlace      bool                    `json:"inplace,omitempty"`
    KeySeparator string                  `json:"keySeparator"`

Config contains the options that dictate the behavior of a transform. The internal `spec` object can be an arbitrary json configuration for the transform.

type ParseError Uses

type ParseError string

ParseError should be thrown when there is an issue with parsing any of the specification or data

func (ParseError) Error Uses

func (p ParseError) Error() string

type RequireError Uses

type RequireError string

RequireError should be thrown if a required key is missing in the data

func (RequireError) Error Uses

func (r RequireError) Error() string

type SpecError Uses

type SpecError string

SpecError should be thrown if the spec for a transform is malformed

func (SpecError) Error Uses

func (s SpecError) Error() string

Package transform imports 9 packages (graph). Updated 2019-07-25. Refresh now. Tools for package owners.