Skip to main content

json

Change a JSON document using delete and set operations. NULL values are kept.

Parameters

NamePropertiesDescriptionDefaultRequiredSupported DB types
columnThe name of the column to be affectedYesjson, jsonb
operationsA list of operations that contains editing delete and setYes-
operationSpecifies the operation type: set or deleteYes-
pathThe path to an object to be modified. See path syntax below.Yes-
valueA value to be assigned to the provided pathNo-
value_templateA Golang template to be assigned to the provided path. See the list of template functions below.No-
error_not_existThrows an error if the key does not exist by the provided path. Disabled by default.falseNo-
skip_not_existSkip operation if the key does not exist.falseNo-

Description

The Json transformer applies a sequence of changing operations (set and/or delete) to a JSON document. The value can be static or dynamic. For the set operation type, a static value is provided in the value parameter, while a dynamic value is provided in the value_template parameter, taking the data received after template execution as a result. Both the value and value_template parameters are mandatory for the set operation.

Path syntax

The Json transformer is based on tidwall/sjson and supports the same path syntax. See their documentation for syntax rules.

Template functions

FunctionDescriptionSignature
.GetPathReturns the current path to which the operation is being applied.GetPath() (path string)
.GetOriginalValueReturns the original value to which the current operation path is pointing. If the value at the specified path does not exist, it returns nil..GetOriginalValue() (value any)
.OriginalValueExistsReturns a boolean value indicating whether the specified path exists or not..OriginalValueExists() (exists bool)
.GetColumnValueReturns an encoded into Golang type value for a specified column or throws an error. A value can be any of int, float, time, string, bool, or slice or map..GetColumnValue(name string) (value any, err error)
.GetRawColumnValueReturns a raw value for a specified column as a string or throws an error.GetRawColumnValue(name string) (value string, err error)
.EncodeValueByColumnEncodes a value of any type into its raw string representation using the specified column name. Encoding is performed through the PostgreSQL driver. Throws an error if types are incompatible..EncodeValueByColumn(name string, value any) (res any, err error)
.DecodeValueByColumnDecodes a value from its raw string representation to a Golang type using the specified column name. Decoding is performed through the PostgreSQL driver. Throws an error if types are incompatible..DecodeValueByColumn(name string, value any) (res any, err error)
.EncodeValueByTypeEncodes a value of any type into its string representation using the specified type name. Encoding is performed through the PostgreSQL driver. Throws an error if types are incompatible..EncodeValueByType(name string, value any) (res any, err error)
.DecodeValueByTypeDecodes a value from its raw string representation to a Golang type using the specified type name. Decoding is performed through the PostgreSQL driver. Throws an error if types are incompatible..DecodeValueByType(name string, value any) (res any, err error)

Example: Changing JSON document

Json transformer example
- schema: "bookings"
name: "aircrafts_data"
transformers:
- name: "Json"
params:
column: "model"
operations:
- operation: "set"
path: "en"
value: "Boeing 777-300-2023"
- operation: "set"
path: "seats"
error_not_exist: True
value_template: "{{ randomInt 100 400 }}"
- operation: "set"
path: "details.preperties.1"
value: {"name": "somename", "description": null}
skip_not_exist: true
- operation: "delete"
path: "values.:2"
Copyright © GreenMask 2026