Open Navigation

Converting between data types

Overview

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.

curly-bracket-notation

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 Helper connector.

text-helper-icon

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 will be the number 42.

typecast-operation

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

typecast-output

Was this article helpful?
Yes
No