JSONToArray

JSONToArray “flattens” a JSON object by selecting specific fields and creating a delimiter-separated string of their values.

A JSON input like {“foo”:”value1”,”bar”:”value2”} can be transformed into a list like value1,value2.

Parameters

Fields

List of strings specifying the JSON keys to retrieve from the input

Separator (default: ,)

The delimited string to insert between each value in the generated string. By default this parameter is set to “,”.

Parameters (from core.SimpleFormatter)

ApplyTo

This value chooses the part of the message the formatting should be applied to. Use “” to target the message payload; other values specify the name of a metadata field to target. By default this parameter is set to “”.

SkipIfEmpty

When set to true, this formatter will not be applied to data that is empty or - in case of metadata - not existing. By default this parameter is set to false

Examples

This example get the foo and bar fields from a json document and create a payload of foo_value:bar_value:

exampleConsumer:
  Type: consumer.Console
  Streams: "*"
  Modulators:
    - format.JSONToArray
      Separator: ;
      Fields:
        - foo
        - bar