Get Data From a JSON Object in Okta Workflows
Last Updated:
Overview
Building Okta Workflows requires reading values from a JavaScript Object Notation (JSON) object, such as a connector or an external API endpoint that returns JSON data. Okta Workflows provides the Object - Get and Object - Get Multiple cards to extract values from JSON objects.
Applies To
- Okta Identity Engine (OIE)
- Okta Classic Engine
- Okta Workflows
Solution
How is the Object - Get card used to extract data?
Use the Object - Get card to read a single JSON value, extract an object, or extract data from a list. Review the following JSON sample used to demonstrate 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
}
}
}
Extract a simple value
Use the Object - Get card to read a JSON value.
Test the card to extract simple text.
Extract an object
Extract the following object by using the ingredients.ingredient.0 path, also known as a key.
{
"id": 100,
"type": "chocolate"
}
Extract the following object by using the shop.inventory path.
{
"instock": 100,
"ordered": 50
}
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
Specify the correct output type when retrieving a JSON value.
| Retrieving Value | Set Output Type To |
|---|---|
| Text | Text |
| Number | Number |
| Object | Object |
| List | Object + List |
Review the four different values extracted in the following image.
Use the Object - Get Multiple card to output multiple values.
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.
Set the output type on the path when using the Object - Get Multiple card.
Test the Object - Get Multiple card to verify the output.
How are keys added to a JSON object?
The User Sign In Attempt event has the Event Details JSON object.
Get the values of the Event Details JSON object by using the Object - Get Multiple card.
The Event Details JSON object contains keys and objects that the card does not expose by default. Expose the keys inside the JSON object, and then connect the values directly to another card without using the Object - Get or Object - Get Multiple card.
NOTE: The Assign and Object - Get Multiple cards produce the same result.
Utilize JSON Utility Tools for Validation and Extraction
Use the following tools to validate, format, and extract values from a JSON sample.
- Use JSON Lint to validate and format a JSON sample.
- Use JSONPath Online Evaluator to extract values from a JSON sample.
NOTE: JSONPath and Okta Workflows utilize different JSON parsers on the backend, meaning not all examples function identically.
