transform

package
v3.4.9+incompatible Latest Latest
Warning

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

Go to latest
Published: Jun 10, 2021 License: MIT Imports: 9 Imported by: 20

Documentation

Overview

Package transform package contains canonical implementations of Kazaam transforms.

Index

Constants

This section is empty.

Variables

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

Functions

func Coalesce

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

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

func Concat

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

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

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

func Delete

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

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

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

func HandleUnquotedStrings

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

jsonparser strips quotes from returned strings, this adds them back

func Pass

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

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

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

func Timestamp

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

Timestamp parses and formats timestamp strings using the golang syntax

func UUID

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

UUID tries to generate a UUID based on spec components

Types

type Config

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

type ParseError string

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

func (ParseError) Error

func (p ParseError) Error() string

type RequireError

type RequireError string

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

func (RequireError) Error

func (r RequireError) Error() string

type SpecError

type SpecError string

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

func (SpecError) Error

func (s SpecError) Error() string

Jump to

Keyboard shortcuts

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