diff --git a/pkg/plugin/processor/builtin/jsonDecode_paramgen.go b/pkg/plugin/processor/builtin/jsonDecode_paramgen.go index b79e0098a..ec30a2f6a 100644 --- a/pkg/plugin/processor/builtin/jsonDecode_paramgen.go +++ b/pkg/plugin/processor/builtin/jsonDecode_paramgen.go @@ -11,7 +11,7 @@ func (jsonDecodeConfig) Parameters() map[string]config.Parameter { return map[string]config.Parameter{ "field": { Default: "", - Description: "field is the target field, as it would be addressed in a Go template (e.g. `.Payload.After`). Applicable values are `.Key`, `.Payload.Before` and `.Payload.After`, as they accept structured data.", + Description: "Field is the target field, as it would be addressed in a Go template (e.g. `.Payload.After`).\nApplicable values are `.Key`, `.Payload.Before` and `.Payload.After`, as they accept structured data format.", Type: config.ParameterTypeString, Validations: []config.Validation{ config.ValidationRequired{}, diff --git a/pkg/plugin/processor/builtin/processors.json b/pkg/plugin/processor/builtin/processors.json index 3301d5e1f..0a8ad4ada 100644 --- a/pkg/plugin/processor/builtin/processors.json +++ b/pkg/plugin/processor/builtin/processors.json @@ -518,6 +518,96 @@ } ] }, + { + "specification": { + "Name": "json.decode", + "Summary": "Decodes a specific field from raw data (string) to JSON structured data.", + "Description": "The processor takes raw data (string) from the target field, parses it as JSON and stores the decoded\nstructured data in the target field.\nThis processor is only applicable to .Key, .Payload.Before and .Payload.After, as they accept structured data format.\n", + "Version": "v0.1.0", + "Author": "Meroxa, Inc.", + "Parameters": { + "field": { + "default": "", + "description": "Field is the target field, as it would be addressed in a Go template (e.g. `.Payload.After`).\nApplicable values are `.Key`, `.Payload.Before` and `.Payload.After`, as they accept structured data format.", + "type": "string", + "validations": [ + { + "type": "required", + "value": "" + }, + { + "type": "inclusion", + "value": ".Key,.Payload.Before,.Payload.After" + } + ] + } + } + }, + "examples": [ + { + "description": "Decode the raw data .Key into structured data.", + "config": { + "field": ".Key" + }, + "have": { + "position": null, + "operation": "create", + "metadata": null, + "key": "{\"after\":{\"data\":4,\"id\":3}}", + "payload": { + "before": null, + "after": null + } + }, + "want": { + "position": null, + "operation": "create", + "metadata": null, + "key": { + "after": { + "data": 4, + "id": 3 + } + }, + "payload": { + "before": null, + "after": null + } + } + }, + { + "description": "Decode the raw data .Payload.Before into structured data.", + "config": { + "field": ".Payload.Before" + }, + "have": { + "position": null, + "operation": "snapshot", + "metadata": null, + "key": null, + "payload": { + "before": "{\"before\":{\"data\":4},\"foo\":\"bar\"}", + "after": null + } + }, + "want": { + "position": null, + "operation": "snapshot", + "metadata": null, + "key": null, + "payload": { + "before": { + "before": { + "data": 4 + }, + "foo": "bar" + }, + "after": null + } + } + } + ] + }, { "specification": { "Name": "unwrap.debezium",