How to Get Data from a JSON Object in Okta Workflows

Updated: May 15, 2024

In this guide:

  1. Okta Workflows guides
  2. Extract data from a JSON object
  3. Okta Workflows resources

Okta Workflows guides

Okta Workflows guides are questions and answers from the community office hours, the #okta-workflows channel on MacAdmins Slack, and other places. Read all the other guides.

How to get data from a JSON object in Okta Workflows?

This guide will teach you how to extract data from a JSON object in Workflows.

Extract data from a JSON object

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.

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:

Reading a JSON value.

Testing this card:

Extracting a simple text.

Extract an object

To extract the following object:

{
"id": 100,
"type": "chocolate"
}

Use the ingredients.ingredient.0 path (also called a key):

Extracting an object.

To extract the following object:

{
   "instock": 100,
   "ordered": 50
}

Use the shop.inventory path:

Extracting an object value.

Extract data from a list

The following example shows how to get a list item with the ingredients.ingredient.1.type path:

Extracting a value from a list.

Set output type

When you get a JSON value, set the correct value output type.

Retrieving valueSet output type to
TextText
NumberNumber
ObjectObject
ListObject + List

The following shows four different value types:

Four output data types: text, number, object, and a list.

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:

Using the Object – Get Multiple card.

The output type is set on the path when using the Object – Get Multiple card.

Testing the card:

Testing the Object – Get Multiple card.

Add keys to a JSON object

You learned how to read JSON values using the Get and Get Multiple cards.

The User Sign In Attempt event has the Event Details JSON object. To get its values, you can use the Get Multiple card:

Extracting JSON values with the Get Multiple card.

The Event Details JSON object has keys/objects the card is not exposing.

You can set up (expose) the keys inside the JSON object. Then, you can connect the values directly to another card without using the Get or Get Multiple card.

Defining keys to extract in the JSON object.

In the screenshot above, the Assign and Get Multiple cards produce the same result.

JSON utility tools

Several tools to help you work 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 use different JSON parsers on the back end. Not all examples will work identically.

Okta Workflows resources

🍫 Get help from Workflows specialists during weekly community office hours.

πŸ“Ί Learn from Workflows videos.

πŸ›Ÿ Get help from support: discuss a Workflows topic or ask a question.

πŸ™‹πŸ»β€β™€οΈ Get help from the community: join the #okta-workflows channel on MacAdmins Slack.

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.