Examples Extracting Values from a JSON Object in Okta Workflows

In this guide:

  1. Okta Workflows guides
  2. Extracting values from JSON
  3. Extracting values from JSON examples
  4. Related Okta Workflows guides
  5. 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.

This guide shows examples of extracting values from a JSON object in Okta Workflows.

Extracting values from JSON

Okta Workflows has two cards to get values from a JSON object:

To learn how to use the cards, read the How to Get Data from a JSON Object in Okta Workflows guide.

Extracting values from JSON examples

Example 1

JSON:

{
  "schemas": [
    "urn:ietf:params:scim:api:messages:2.0:ListResponse"
  ],
  "totalResults": 1,
  "Resources": [
    {
      "id": "xxxx-7383-4848-960f-2514cdf3adbc",
      "userName": "tango.xxxx@preply.com",
      "name": {
        "givenName": "TFam",
        "familyName": "Guest"
      },
      "department": "marketing",
      "permissions": {
        "companyPermissions": [],
        "appGroup": [
          {
            "appGroupId": "xxx-313a-xxx-xx-b9f4e6c9beb3",
            "appGroupName": "Happy",
            "appGroupPermissions": [
              "view_user_profile"
            ]
          }
        ]
      },
      "lastSignInAt": "2023 May 15, 5:59 PM"
    }
  ]
}

Key:

Resources.0.id

Result:

xxxx-7383-4848-960f-2514cdf3adbc

The flow looks like this:

Extracting value from a JSON object.

Example 2

This example is how to extract a value where a key has a dot (.) in it.

Extracting a value where a key has a dot in it.

Result:

Extracting a value where a key has a dot in it.

Example 3

JSON:

{
  "users": [
    {
      "id": 5040,
      "name": "Eric TestUser",
      "username": "eric.testuser@testcompany.com",
      "active": true,
      "balance": "0.0",
      "last_edited_date": "2023-03-02T03:07:22.000Z",
      "creation_date": "2023-03-01T20:04:27.000Z"
    }
  ],
  "meta": {
    "total": 1,
    "offset": 0,
    "limit": 50
  }
}

Key:

users.0.id

Result:

5040

Example 4

JSON:

[
  {
    "encodedKey": "8a195f307039cbf9017042f6ecf00045",
    "id": 1,
    "creationDate": "2020-02-14T09:10:44+0000",
    "lastModifiedDate": "2022-09-07T11:42:02+0000",
    "lastLoggedInDate": "2021-08-11T08:03:48+0000",
    "username": "XXX",
    "email": "user1@email.com",
    "title": "ADMIN",
    "firstName": "Super",
    "lastName": "Champion",
    "homePhone": "",
    "mobilePhone1": "",
    "language": "ENGLISH",
    "userState": "ACTIVE",
    "twoFactorAuthentication": false,
    "isAdministrator": true,
    "isTeller": false,
    "isCreditOfficer": false,
    "isSupport": false,
    "isDelivery": false,
    "accessRights": [
      "ADMIN",
      "APIS"
    ],
    "managedBranches": [],
    "notes": "",
    "isApiConsumer": false,
    "isDeletable": false,
    "failedLoginsCount": 7,
    "failedLoginsDates": [
      "2021-09-01T08:57:25+0000",
      "2022-03-16T09:34:59+0000",
      "2022-03-16T09:40:27+0000",
      "2022-03-16T09:40:46+0000",
      "2022-09-14T13:14:50+0000",
      "2022-09-14T13:15:10+0000",
      "2022-09-15T14:55:00+0000"
    ],
    "provisionedThroughFederation": false
  }
]

Keys:

Extracting multiple keys with the Object – Get Multiple card.

Result:

Extracting multiple keys with the Object – Get Multiple card.

Example 5

JSON

[
  {
    "timestamp": "2022-09-21T13:59:02.949278-04:00",
    "version": 1,
    "type": "nodeNeedsApproval",
    "tailnet": "example.com",
    "message": "Node name.workstation1a.net needs approval",
    "data": {
      "nodeID": "X3BQa9Xkvf",
      "deviceName": "name.workstation1a.net",
      "managedBy": "name@example.com",
      "actor": "name@example.com",
      "url": "https://login.example.com/admin/machines/001.02.345.67"
    }
  }
]

Key:

0

Result

{
  "timestamp": "2022-09-21T13:59:02.949278-04:00",
  "version": 1,
  "type": "nodeNeedsApproval",
  "tailnet": "example.com",
  "message": "Node name.workstation1a.net needs approval",
  "data": {
    "nodeID": "X3BQa9Xkvf",
    "deviceName": "name.workstation1a.net",
    "managedBy": "name@example.com",
    "actor": "name@example.com",
    "url": "https://login.example.com/admin/machines/001.02.345.67"
  }
}

Key:

0.message

Result:

Node name.workstation1a.net needs approval

Key:

0.message.nodeID

Result:

X3BQa9Xkvf
Extracting JSON values with the Object β€” Get Multiple card.
Extracting JSON values with the Object β€” Get Multiple card results.

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