Converting Between Types


Sometimes you'll need to convert values between types.  For example, an API may return an ID as a string and you need to compare it to a number.  Usually this is needed when using the boolean connector to do a comparison between two values.

There are several ways to handle this in tray.  The simplest way is often to convert everything to a string before comparison. 

If you use the curly bracket notation you can set the types of both fields to be strings which will ensure the correct comparison.

This will serve most purposes.  If you wish to covert a String into a number or a boolean then you can use the Typecast operation in the Text Helpers connector.

The Typecast operation takes any string as input and determines the type that it should be outputted as.  For example if the input is the string "42" then the output of the connector with be the number 42.

We can see from the logs that the type conversion has been successful.

Last updated 12th April 2017