Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ExpressionEvaluator ¶
ExpressionEvaluator are low level APIs for the evaluation of expressions provided by the user inside the JSON transformation.
type JSONTransformer ¶
type JSONTransformer struct {
// contains filtered or unexported fields
}
JSONTransformer transforms JSON input data of a file into output data using a set of transformation descriptions
func NewJSONTransformer ¶
func NewJSONTransformer(transformJSON []byte, opts ...Option) (*JSONTransformer, error)
NewJSONTransformer instantiates a new instance of a JSONTransformer struct which is used to perform the transformation of input JSON data by following instructions given in a JSON format as well. This JSON giving the transformation description has to be provided as bytes as an input to this function.
As further input, this function takes a list of options which allows certain control of the transformation behavior. See config.go for a list of configuration options.
This function returns an error if the provided transformation bytes are not valid JSON.
func NewJSONTransformerWithFile ¶
func NewJSONTransformerWithFile(transformFile string, opts ...Option) (*JSONTransformer, error)
NewJSONTransformerWithFile instantiates a new instance of a JSONTransformer struct which is used to perform the transformation of input JSON data by following instructions given in a JSON format as well. Unlike the instantiation using NewJSONTransformer(), this function takes a filesystem path to a file that contains the JSON with transformation instructions. The path can be either relative to the execution context of the program or absolute on the system.
As further input, this function takes a list of options which allows certain control of the transformation behavior. See config.go for a list of configuration options.
This function returns an error in at least one of the following cases:
(1) the provided filesystem path is not valid
(2) the provided transformation bytes are not valid JSON
func (*JSONTransformer) Transform ¶
func (j *JSONTransformer) Transform(inJSON []byte) ([]byte, error)
Transform takes as an input a JSON as byte array and applies the JSONTransformer's transformation description on the provided data. In case of a successful transformation, the output JSON is returned as byte array.
This function returns an error in at least one of the following cases:
(1) the provided input bytes are not valid JSON
(2) an instruction of the transformation description cannot be performed due to invalid syntax of the expression or wrong input data types
func (*JSONTransformer) TransformWithFile ¶
func (j *JSONTransformer) TransformWithFile(inJSONFile string) ([]byte, error)
TransformWithFile takes JSON data as an input and applies the JSONTransformer's transformation description on the provided data. In case of a successful transformation, the output JSON is returned as byte array. Unlike Transform(), which accepts raw JSON bytes as input, this function takes a filesystem path to a file that contains the JSON to be transformed. The path can be either relative to the execution context of the program or absolute on the system.
This function returns an error in at least one of the following cases:
(1) the provided filesystem path is not valid
(2) the provided input bytes are not valid JSON
(3) an instruction of the transformation description cannot be performed due to invalid syntax of the expression or wrong input data types
type Option ¶
type Option interface {
// contains filtered or unexported methods
}
Option is a configuration option of the JSONTransformer and forms part of the functional options pattern described, e.g., in the Uber Go Style Guide: https://github.com/uber-go/guide/blob/master/style.md#functional-options