This article demonstrates how to convert a string into an array using Okta's Expression Language. This process can be particularly useful in attribute mapping, where transforming data types may be necessary for specific operations or applications.
- Attribute mapping
- String to Array conversion
- Okta Expression Language (OEL)
In specific scenarios, it may be necessary to convert a string to an array in Okta, particularly during attribute mapping processes. The Okta Expression Language provides a set of array functions that can facilitate this type of data transformation.
To convert a string to an array, combine two array functions in the Okta Expression Language as follows:
Arrays.add(Arrays.toCsvString({}),<string>)
- In this expression, replace
<string>with the variable to map or specific text as per the requirements. - Convert an empty array to a CSV string using the
Arrays.toCsvString({})function, and then using theArrays.add()function to add the specific string to this array. The end result will be an array that contains the specified string as an element. - The function can be expanded to include multiple values in the array from different attribute sources by enclosing the expression in another
Arrays.add(arrayPlacedHere,newStringHere)expression as follows:
Arrays.add(Arrays.add(Arrays.toCsvString({}),<string>),<string2>)
Example:
