Building workflows requires reading values from a JSON object, such as a connector that returns JSON data or an external API endpoint that returns JSON data.
Okta Workflows has two cards to get values from JSON:
- Object – Get card
- Object – Get Multiple card
- Okta Workflows
This guide will use the following JSON to show how the cards work:
{
"product": "ice cream",
"ingredients": {
"ingredient": [{
"id": 100,
"type": "chocolate"
},
{
"id": 200,
"type": "vanilla"
},
{
"id": 300,
"type": "caramel"
}
]
},
"shop": {
"inventory": {
"instock": 100,
"ordered": 50
}
}
}
Use the Object – Get card
- Extract a simple value
Use the Object – Get card to read a JSON value:
Testing this card:
- Extract an object
- To extract the following object:
{ "id": 100, "type": "chocolate" }
- To extract the following object:
Use the ingredients.ingredient.0 path (also called a key):
-
- To extract the following object:
{ "instock": 100, "ordered": 50 }
- To extract the following object:
Use the shop.inventory path:
- Extract data from a list
The following example shows how to get a list item with the ingredients.ingredient.1.type path:
- Set output type
When retrieving a JSON value, specify the correct output type.
| Retrieving value | Set output type to |
|---|---|
| Text | Text |
| Number | Number |
| Object | Object |
| List | Object + List |
The following shows four different value types:
Using the Object – Get Multiple card
The Object – Get card outputs a single JSON path. The Object – Get Multiple card works similarly and outputs multiple values.
Enter multiple paths (or keys) to get values:
The output type is set on the path when using the Object – Get Multiple card.
Testing the card:
Add keys to a JSON object
How to read JSON values using the Get and Get Multiple cards has been covered.
The User Sign In Attempt event has the Event Details JSON object. To get its values, use the Get Multiple card:
The Event Details JSON object contains keys/objects that the card does not expose.
Set up (expose) the keys inside the JSON object. Then, connect the values directly to another card without using the Get or Get Multiple card.
In the screenshot above, the Assign and Get Multiple cards produce the same result.
JSON utility tools
Several tools to help with working with JSON:
- Use JSON Lint to validate and format a JSON sample.
- Use JSONPath Online Evaluator to extract values from a JSON sample.
- JSONPath and Okta Workflows utilize different JSON parsers on the backend. Not all examples will work identically.
