Okta Workflows How-To: Convert an Object to a List

About the Author

Max Katz

Staff Developer Advocate, Okta Workflows

Max Katz is a Staff Developer Advocate for Okta Workflows. Max loves the no-code automation space and creating educational content. Before Okta, Max led the North America Developer Advocacy team at IBM. Before IBM, Max led developer advocacy for a cloud-based mobile app platform, Appery, helping it grow from zero to over 400,000 developers. Max regularly writes on his http://maxkatz.net blog. 

12 December 2022 Time to read: ~

Okta Workflows is a no-code platform for automating identity processes. 

This blog post is based on a question asked during office hours or the #okta-workflows channel in MacAdmins Slack: How to convert an object to a list (or how to use the Object – Map to List card)? 

Getting started

Object – Map to List card takes an object and converts it to a list using a helper flow.

For example, if you have this object:

{
  "drink": "wine",
  "main course": "chicken",
  "appetizer ": "salad",
  "desert": "ice cream"
}

You can convert it to a list where each property from the object becomes a key/value pair:

[
   {
      "key": "drink",
      "value": "wine"
   },
   {
      "key": "main course",
      "value": "chicken"
   },
   {
      "key": "appetizer",
      "value": "salad"
   },
   {
      "key": "desert",
      "value": "ice cream"
   }
]

This is the main flow:

Converting an object to a list flow

And the is the helper flow:

Helper flow converting an object to a list

Result running the flow:

[
  {
     "key": "drink",
     "value": "wine"
  },
  {
     "key": "main course",
     "value": "chicken"
  },
  {
     "key": "appetizer ",
     "value": "salad"
  },
  {
     "key": "desert",
     "value": "ice cream"
  }
]

You can also pass additional information to the helper flow, for example, if you need to pass in a prefix (dinner) to get the following result:

[
   {
      "key": "dinner:drink",
      "value": "wine"
   },
   ...
]

The updated main flow with a constant prefix passed to the helper flow:

Converting an object to a list flow with prefix

In the update helper flow, the prefix is concatenated with the key to create a new key value:

Helper flow converting an object to a list with prefix

Result running the updated flow:

[
   {
      "key": "dinner:drink",
      "value": "wine"
   },
   {
      "key": "dinner:main course",
      "value": "chicken"
   },
   {
      "key": "dinner:appetizer ",
      "value": "salad"
   },
   {
      "key": "dinner:desert",
      "value": "ice cream"
   }
]

In this how-to you learned how to use the Object – Map to List card.

Get your Workflows questions answered

Do you have a question about Okta Workflows? Not sure how to build a flow? Join the weekly community office hours to get help.

About the Author

Max Katz

Staff Developer Advocate, Okta Workflows

Max Katz is a Staff Developer Advocate for Okta Workflows. Max loves the no-code automation space and creating educational content. Before Okta, Max led the North America Developer Advocacy team at IBM. Before IBM, Max led developer advocacy for a cloud-based mobile app platform, Appery, helping it grow from zero to over 400,000 developers. Max regularly writes on his http://maxkatz.net blog. 

Continue your Identity journey