Workflows Tips #42: Creating a JSON Object, Searching a JSON Object, and Using the List-Reduce Card

Welcome to another Okta Workflows Tips post. Read all previous tips.

In this post:

  • Creating a JSON object
  • Searching a JSON object
  • Reducing a list to a single value (how to use the List-Reduce card)

Creating a JSON object

Here is how to create a JSON object using the Object-Construct card:

Creating a JSON object

Note that field names were renamed, and the result is this JSON object:

Testing the Object-Construct card

Although it is possible to use the Text-Compose card to create a JSON object, it is recommended to use the Object-Construct card. Using the Construct card is less error-prone.

Searching a JSON object

Thanks to Bryan Barrows (Workflows Product Specialist at Okta) for sharing this flow.

This example from Bryan shows how to search a JSON object.

Searching a JSON object

You can download the JSON file used in this example.

The goal is to find the Battery Condition value.

This is how the flow works:

  1. The first card, the JSON-Parse card, creates the JSON object from a string. In your situation, you might be getting the JSON from another card such as a search or API call
  2. The List-Filter card finds the objects where the name is set to Battery Condition
  3. The List-Collapse card transforms a list of objects into a single object
  4. And finally, the Object-Get Multiple card retrieves the value property that holds that battery condition
Searching a JSON object result

Reducing a list to a single value (how to use the List-Reduce card)

This blog post has three examples of how to use the List-Reduce card.

Reducing a list to a single value

The examples are:

  • A list of numbers – sum all the numbers
  • A list of numbers – find the largest (or smallest) number
  • A list of messages (text) – create a single message containing all the messages from a list

Read the blog post.

Two resources to help you learn more

🎥 Short how-to Workflows videos to help you become a better automation builder.

📘 Read our Workflows How-To Guides based on community member questions.

Published by

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

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