How to Create JSON Data in Okta Workflows
Last Updated:
Overview
Administrators can create JavaScript Object Notation (JSON) data in Okta Workflows using a string, the Object - Construct card, or a nested JSON object. Generating JSON data structures allows administrators to use the data in various workflow automations and Application Programming Interface (API) requests.
Applies To
- Okta Identity Engine (OIE)
- Okta Classic Engine
- Okta Workflows
Solution
What are the steps to create and format JSON from a string in a Workflow?
Create a typed JavaScript Object Notation (JSON) data structure by reviewing the required string format and using the JSON - Parse card to parse the string from the Compose card.
- Review the following example JSON string to understand the required structure.
{ "name": "Jane", "description": "Standard user", "email": "user@example.com", "features": { "SSO": "on", "MFA": "on", "Workflows": "on" } }
- Use the JSON - Parse card to create a typed JSON data structure from the string in the Compose card.
The result of running this flow is:
The JSON – Parse card returns a JSON object that is usable with other cards:
It is also possible to pass data from other cards to create the JSON dynamically:
What are the steps to create and format JSON with the Object – Construct card in a Workflow?
Configure the Object - Construct card to build a JSON object by defining the required keys and values and testing the card to verify the output.
- Configure the Object - Construct card to build a JSON object by defining the required keys and values.
- Test the card to verify the resulting JSON object output.
Using the Object–Construct card is handy when it is needed to create headers for an API service:
The card creates the following JSON object:
{
"X-Favorite-Food": "Pizza",
"X-Favorite-Drink": "Tea"
}
What are the steps to create and format a nested JSON object in a Workflow?
Create a nested JSON object using the Object - Construct card by setting the field name with dot notation and testing the card to generate the nested structure.
- Create a nested JSON object using the Object - Construct card by setting the field name with dot notation, such as
user.email.
- Test the card to generate the nested structure.
Review the resulting nested JSON output.
{
"user": {
"email": "user@okta.com"
}
}
