<iframe src="https://www.googletagmanager.com/ns.html?id=GTM-M74D8PB" height="0" width="0" style="display:none;visibility:hidden">
Loading
Skip to NavigationSkip to Main Content

Get Data From a JSON Object in Okta Workflows

Workflows
Okta Classic Engine
Okta Identity Engine

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.

Reading a JSON value

Test the card to extract simple text.

Extracting a 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"
}

Extracting an object

Extract the following object by using the shop.inventory path.

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

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

Specify the correct output type when retrieving a JSON value.

Retrieving ValueSet Output Type To
TextText
NumberNumber
ObjectObject
ListObject + List

Review the four different values extracted in the following image.

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

    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.

    Using the Object – Get Multiple card

    Set the output type on the path when using the Object - Get Multiple card.

    Test the Object - Get Multiple card to verify the output.

    Testing the Object – Get Multiple card

    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.

    Extracting JSON values with the 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.

    Defining keys to extract in the JSON object

    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.

    NOTE: JSONPath and Okta Workflows utilize different JSON parsers on the backend, meaning not all examples function identically.

     

    Related References

    Loading
    Okta Support - Get Data From a JSON Object in Okta Workflows