Skip to content

Json serializer ​

Converts the input object to JSON text. The records of a batch (e.g. one Sql query execution, one JSON array from Json deserializer, one file read) are serialized together into one JSON array when the batch completes; records without a batch become one JSON object each.

Pins ​

PinKindTypesDescription
InputinputanyThe object(s) to serialize.
OutputoutputViaducta.Plugins.TextPlugin.Types.TextRecordThe JSON in Value, ContentType = application/json (Name is not set).

Configuration ​

FieldTypeDefaultDescription
IndentedbooleantruePretty-printed (true) or compact (false) JSON.
IgnoreInternalFieldsbooleantrueLeaves out the internal recordId field.
SkipValidationbooleanfalseNot used (see Notes).
BatchScopebatch scope selectoremptyWhich batch is serialized into one JSON. Empty = the closest batch producer upstream. A component id of a batch producer upstream = the batches of that producer. None = ignore batches.
MaxDepthinteger 0-10000Maximum nesting depth; 0 means the default (64 in .NET).
DefaultIgnoreConditiondropdown: 0 Never, 1 Always, 2 WhenWritingDefault, 3 WhenWritingNull0Which property values are left out: 3 skips nulls, 2 skips nulls and default values (0, false, ...).
Behaviourdropdown: 0 None, 1 AlwaysSerializeArray01: empty input (NoInputData) gives [], and a batch with one record gives a one-element array.

Behaviour ​

  • Records in a batch (see BatchScope) are collected per batch. When the whole batch has been processed they are serialized and emitted as one TextRecord: a JSON array, or a JSON object when the batch has a single record (an array with Behaviour = 1). The record carries the metadata of the last record and stays in the batch, so batch consumers behind it (Write file, ...) include it before they commit. When the batch failed nothing is emitted. Concurrent batches never mix.
  • Records without a batch, or BatchScope None: one TextRecord per input, containing a JSON object (or [] for NoInputData with Behaviour = 1).

Notes ​

  • A batch is emitted only after the whole batch was processed: the JSON of a large batch is built in memory.
  • SkipValidation is ignored by the code.
  • DefaultIgnoreCondition = 1 (Always) is not accepted by the .NET serializer and makes serialization fail.
  • MaxDepth description in the designer says 0 means 1000; the .NET default for 0 is 64.

Example ​

json
{ "Indented": false, "DefaultIgnoreCondition": 3, "Behaviour": 1 }

Timer → Sql query → Json serializer → Write file (one JSON file per query execution)

Viaducta documentation