ToJSON¶
This formatter converts metadata to JSON and stores it where applied.
Parameters¶
Root
The metadata key to transform to json. When left empty, all metadata is assumed. By default this is set to ‘’.
Ignore
A list of keys or paths to exclude from marshalling. please note that this is currently a quite expensive operation as all metadata below root is cloned during the process. By default this is set to an empty list.
Parameters (from core.SimpleFormatter)¶
Source
This value chooses the part of the message the data to be formatted should be read from. Use “” to target the message payload; other values specify the name of a metadata field to target. By default this parameter is set to “”.
Target
This value chooses the part of the message the formatted data should be stored 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 “”.
ApplyTo
Use this to set Source and Target to the same value. This setting will be ignored if either Source or Target is set to something else but “”. 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 transforms all metadata below the “foo” key to JSON and stores the result as the new payload.
exampleProducer:
Type: consumer.Producer
Streams: stdin
Modulators:
- format.ToJSON
Root: "foo"