Data Converter

Updated 3 months ago by Karan

In this step-by-step guide, you will understand how to use a data converter (pipe) for optimizing the data in the relevant format.

Usage

By default, all data is sent as a string, but the data converters can be used to send the data in the appropriate format. For example, if the Airtable column is configured as a number, it should be sent in that format only.

The pipe is used to convert data format in various task nodes of a Byteline flow.

Pipe Converter

The pipe| can be placed where the default data string ends for converting such data into the relevant format.

For example,

@.data.created | datetime

Here, you can see that the input data fetched with the syntax is @.data.created and has been instructed to convert intodatetimeformat by using a pipe.

Number

To convert input data to numerical format use the syntax :

${input.field1}| number

Boolean

To convert input data to boolean format use the syntax :

${input.field1}| bool

DateTime

To convert input data to datetime format use the syntax :

${input.field1}| datetime

Replace

To replace any value use the syntax :

${input.field1}| replace('/','')

It supports two variants:

Literal String Replacement

To replace a string use the syntax:

${input.field1}| replace('value1','value2')

Regular Expressions

To replace using regular expression use the below syntax. The true flag is required for regular expressions.

${input.field1}| replace('regex','value2',true)

Maxlength

When the string is too lengthy then maxlength can be used to just keep the first n characters from a string. You can pass any integer value as the argument.

To limit the maxlength of the string use the syntax:

${input.field1}| maxlength(n)

Array

It converts a comma-separated string into an array. This will usually be required when the data type required by a third-party system is an array.

To convert comma-separated data into an array use the syntax:

${input.field1}| array

SHA-1 Converter

Sha1 is used to calculate an alphanumeric string, serving as a cryptographic representation of data. In Byteline, you can now use SHA-1 converter to carry out Hex, Base64, and HMAC encoding.

You can use Sha1 in the following three ways:

  • ${input.field1} | sha1 

This is the basic format in which users don't have to pass any argument. However, the default is hex encoding.

  • ${input.field1} | sha1(‘base64’)

In this, you have to pass an argument if you want to use base64 encoding instead of the default ('Hex') encoding.

  • ${input.field1} | sha1(‘base64’, ‘key1’)

You can even pass the second argument in the Sha1 converter. In this, you need to pass a key to perform HMAC encoding.

Thus you can use a data converter in your nodes to set them into the right format. Feel free to connect us for any doubt.


How did we do?