Using the Cast Component in Liquid Data Mapper

Liquid Data Mapper is a versatile tool for transforming diverse data formats like CSV, EDI, and JSON. It includes the Cast Component to convert incompatible data types, such as transforming a string date into an EDI-required format. Users can customize properties and format specifications for accurate data casting.


Liquid Data Mapper is a powerful data mapping tool supporting advanced transformation of data in a variety of formats such as CSV, Database, EDI, JSON, Web Services and XML.

Using the Cast Component

The Cast Component provides a mechanism for converting data types which cannot be automatically converted.

For example, in EDI the ‘Date of preparation’ field requires a 6 digit date such as ‘170621’.

Using the Cast Component in Liquid Data Mapper

However, if we connect a Const Component with this sting value we will see an error message when we run the transform:

‘The format of the value ‘170621’ is incorrect for casting from a String to Date.

Using the Cast Component in Liquid Data Mapper

In order to support this we can use the Cast Component.

Using the Cast Component in Liquid Data Mapper

Cast Component Properties

After adding the Cast Component, we need to set the cast properties. To show the properties dialog, we can either double click the component, right click the component and select ‘Show Properties’ or use the short cut ‘Shift+F4’.
We will need to change the Cast Type to be ‘Date’ or ‘DateTime’ and set the Casting rule to be ‘Customizable DateTime’.
 
Then we can set the Format Specifiers to match the format of the input string data ‘ddMMyy’. The format string follows the rules of the Microsoft .Net Standard date and time format strings.

Cast Component

Now when we run the transform, the string value is correctly written in the required EDI date format.

Further Reading

Please see the data mapper documentation for additional information about casting various data types in Liquid Data Mapper.

Download a Free Trial of Liquid Data Mapper:
https://www.liquid-technologies.com/trial-download

Discover more from Liquid Technologies Blog

Subscribe now to keep reading and get access to the full archive.

Continue reading