Skip to main content
Version: 1.2.0

Serialize

Data Processing Data Export Format Conversion

Synopsis

A data transformation processor that converts structured data into serialized formats including JSON, XML, CSV, TSV, and custom delimited formats, enabling data export and format standardization across different systems.

Schema

- serialize:
type: <enum>
fields: <string[]>
source_field: <ident>
target_field: <ident>
delimiter: <string>
description: <text>
if: <script>
ignore_failure: <boolean>
ignore_missing: <boolean>
include_header: <boolean>
quote_char: <string>
escape_char: <string>
root_element: <string>
xml_namespace: <string>
xml_template: <string>
xml_attribute: <string>
omit_xml_declaration: <boolean>
use_root_as_element: <boolean>
on_failure: <processor[]>
on_success: <processor[]>
tag: <string>

Configuration

The following fields are used to define the processor:

FieldRequiredDefaultDescription
typeY-Serialization format: json, xml, csv, tsv, or delimited
fieldsNall fieldsFields to serialize (supports wildcards and exclusions)
source_fieldNtop-levelSource field containing data to serialize
target_fieldN_rawField to store the serialized output
delimiterN,Delimiter for custom delimited format
include_headerNfalseInclude header row for CSV/TSV/delimited
quote_charN"Quote character for CSV/delimited formats
escape_charN-Escape character for CSV/delimited formats
root_elementNrootRoot element name for XML output
xml_namespaceN-XML namespace URI
xml_templateN-XML element template name
xml_attributeN-XML attribute name for templated output
omit_xml_declarationNfalseOmit XML declaration header
use_root_as_elementNfalseUse single key as root element
descriptionN-Explanatory note
ifN-Condition to run
ignore_failureNfalseContinue if serialization fails
ignore_missingNfalseContinue if source field doesn't exist
on_failureN-See Handling Failures
on_successN-See Handling Success
tagN-Identifier

Details

The processor supports multiple serialization formats with format-specific configuration options. Field selection allows precise control over which data elements are included in the serialized output.

note

Field selection supports wildcard patterns (*) and exclusions (!fieldname) for flexible data filtering.

JSON serialization provides compact, standards-compliant output suitable for APIs and data interchange. XML serialization offers extensive customization including namespaces, templates, and attribute-based formatting for enterprise integration scenarios.

CSV and TSV formats support header generation and custom delimiters for data analysis and reporting workflows. The delimited format provides maximum flexibility with configurable separators, quotes, and escape characters.

warning

Large datasets may impact performance - consider filtering fields to optimize serialization speed.

Examples

JSON Serialization

Converting structured data to JSON...

{
"user": {
"id": 123,
"name": "John Doe",
"email": "john@example.com",
"active": true
}
}
- serialize:
type: json
source_field: user
target_field: user_json

produces JSON string:

{
"user": {
"id": 123,
"name": "John Doe",
"email": "john@example.com",
"active": true
},
"user_json": "{\"id\":123,\"name\":\"John Doe\",\"email\":\"john@example.com\",\"active\":true}"
}

XML Serialization

Converting data to XML format...

{
"config": {
"database": "production",
"timeout": 30,
"enabled": true
}
}
- serialize:
type: xml
source_field: config
target_field: config_xml
root_element: Configuration

creates structured XML:

{
"config": {
"database": "production",
"timeout": 30,
"enabled": true
},
"config_xml": "<?xml version=\"1.0\" encoding=\"UTF-8\"?><Configuration><database>production</database><enabled>true</enabled><timeout>30</timeout></Configuration>"
}

CSV with Header

Exporting data as CSV with header...

{
"record": {
"id": "001",
"product": "Widget A",
"price": 19.99,
"quantity": 5
}
}
- serialize:
type: csv
source_field: record
target_field: csv_output
include_header: true

generates CSV format:

{
"record": {
"id": "001",
"product": "Widget A",
"price": 19.99,
"quantity": 5
},
"csv_output": "id,price,product,quantity\n001,19.99,Widget A,5"
}

Field Selection

Serializing specific fields only...

{
"user_data": {
"id": 456,
"username": "jane_doe",
"password": "secret123",
"email": "jane@example.com",
"last_login": "2024-01-15T10:30:00Z"
}
}
- serialize:
type: json
source_field: user_data
target_field: public_data
fields: ["id", "username", "email"]

excludes sensitive information:

{
"user_data": {
"id": 456,
"username": "jane_doe",
"password": "secret123",
"email": "jane@example.com",
"last_login": "2024-01-15T10:30:00Z"
},
"public_data": "{\"email\":\"jane@example.com\",\"id\":456,\"username\":\"jane_doe\"}"
}

XML with Attributes

Creating XML with attribute-based format...

{
"event_data": {
"EventID": "4624",
"Level": "Information",
"Source": "Security",
"Computer": "SERVER01"
}
}
- serialize:
type: xml
source_field: event_data
target_field: event_xml
root_element: Event
xml_template: Data
xml_attribute: Name

produces Windows Event-style XML:

{
"event_data": {
"EventID": "4624",
"Level": "Information",
"Source": "Security",
"Computer": "SERVER01"
},
"event_xml": "<?xml version=\"1.0\" encoding=\"UTF-8\"?><Event><Data Name=\"Computer\">SERVER01</Data><Data Name=\"EventID\">4624</Data><Data Name=\"Level\">Information</Data><Data Name=\"Source\">Security</Data></Event>"
}

Custom Delimited Format

Creating pipe-delimited output...

{
"metrics": {
"cpu_usage": 75.2,
"memory_usage": 68.5,
"disk_usage": 45.3,
"network_io": 1024
}
}
- serialize:
type: delimited
source_field: metrics
target_field: metrics_pipe
delimiter: "|"
include_header: true

creates pipe-separated values:

{
"metrics": {
"cpu_usage": 75.2,
"memory_usage": 68.5,
"disk_usage": 45.3,
"network_io": 1024
},
"metrics_pipe": "cpu_usage|disk_usage|memory_usage|network_io\n75.2|45.3|68.5|1024"
}