How to Read a JSON Path With Dot-Notation in Workflows
Tags: nocode, workflows, okta, ipaas
Published: 2022-08-29 18:45:35

---
title: How to Read a JSON Path With Dot-Notation in Workflows
published: true
date: 2022-08-29 03:56:55 UTC
tags: NoCode,Workflows,okta, ipaas
canonical_url: https://maxkatz.net/2022/05/18/how-to-read-a-json-path-with-dot-notation-in-workflows/
---

[Okta Workflows](https://www.okta.com/platform/workflows/) how-to guides are questions and answers from weekly community [office hours](https://calendly.com/oktaworkflows/group-office-hours-okta-workflows), MacAdmins [Workflows Slack channel](https://www.macadmins.org/), and other places. 

Read all the other how-to guides ⤵️
{% embed https://dev.to/oktaworkflows/all-okta-workflows-how-to-guides-4nl9 %}

On to the question. 

**_How to read a JSON path with dot-notation?_**

As you build workflow automations it is likely you will need to read values from a JSON object. For example, from an external API endpoint that returns data as JSON. Workflows has two cards to help read (retrieve) values from JSON:

- **Object – Get**
- **Object – Get Mutliple**

We 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
      }
   }
}
```

The dot-notation is a path that corresponds to an _item_ in JSON.

For example, a path of `product` will return:

```
ice cream
```

## Using Object – Get card to read JSON

In Workflows, use the **Object – Get** to read a JSON path:

[![Get card for reading JSON path data](https://katzmax.files.wordpress.com/2022/05/workflows_howto_json1.png?w=498)](https://katzmax.files.wordpress.com/2022/05/workflows_howto_json1.png)
<figcaption>Get card for reading JSON path data</figcaption>

Testing this card:

[![Testing Get card](https://katzmax.files.wordpress.com/2022/05/workflwos_howto_json1ab.png?w=1024)](https://katzmax.files.wordpress.com/2022/05/workflwos_howto_json1ab.png)
<figcaption>Testing Get card</figcaption>

Let’s look at more examples.

Using the path `ingredients.ingredient.0` will result in:

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

this is how it looks when testing using **Object – Get** card:

[![Using dot-notation in path](https://katzmax.files.wordpress.com/2022/05/workflows_howto_json2.png?w=1024)](https://katzmax.files.wordpress.com/2022/05/workflows_howto_json2.png)
<figcaption>Using dot-notation in path</figcaption>

One thing to keep in mind is that the output type needs to match the JSON type. If the path you entered retrieves a plain text then the type should be **Text**. If the path retrieves an object then the type should be set to **Object** (or you will get incorrect results).

Using the above example, setting the output type to **Text** will result in this:

[![Testing Get card with incorrect output type](https://katzmax.files.wordpress.com/2022/05/workflows_howto_json3_type.png?w=1024)](https://katzmax.files.wordpress.com/2022/05/workflows_howto_json3_type.png)
<figcaption>Testing Get card with incorrect output type</figcaption>

Setting correct output type:

[![Testing Get card with correct output type](https://katzmax.files.wordpress.com/2022/05/workflows_howto_setting_type.png?w=504)](https://katzmax.files.wordpress.com/2022/05/workflows_howto_setting_type.png)
<figcaption>Testing Get card with correct output type</figcaption>

This example shows how access an array with `ingredients.ingredient.1.type`:

[![Accessing array using dot-notation path](https://katzmax.files.wordpress.com/2022/05/workflows_howto_json4_array.png?w=1024)](https://katzmax.files.wordpress.com/2022/05/workflows_howto_json4_array.png)
<figcaption>Accessing array using dot-notation path</figcaption>

Note that the output type is set to **Text** as the output is a string.

One more example using the path of `shop.inventory` will return

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

[![Testing Get card to access a JSON object](https://katzmax.files.wordpress.com/2022/05/workflows_howto_json5.png?w=1024)](https://katzmax.files.wordpress.com/2022/05/workflows_howto_json5.png)
<figcaption>Testing Get card to access a JSON object</figcaption>

Note that the output type is set to **Object** as the output is an object.

## Using Object – Get Multiple to read JSON

**Object – Get** outputs a single JSON path, **Object – Get Multiple** works the same and can output multiple paths. You enter any number of paths you need as output:

[![Using Get Multiple card](https://katzmax.files.wordpress.com/2022/05/workflows_howto_multiple_2a.png?w=440)](https://katzmax.files.wordpress.com/2022/05/workflows_howto_multiple_2a.png)
<figcaption>Using Get Multiple card</figcaption>

Note the the output type is set on the path itself when using **Object – Get Multiple** card.

[![Testing Get Multiple card](https://katzmax.files.wordpress.com/2022/05/workflwos_howto_multiple2.png?w=1024)](https://katzmax.files.wordpress.com/2022/05/workflwos_howto_multiple2.png)
<figcaption>Testing Get Multiple card</figcaption>

The [JSONPath Online Evaluator](https://jsonpath.com/) is an online tool where you can test your dot-notation paths.

[![JSONPath online evaluator tool](https://katzmax.files.wordpress.com/2022/05/workflows_howto_json_test_tool.png?w=1024)](https://katzmax.files.wordpress.com/2022/05/workflows_howto_json_test_tool.png)
<figcaption>JSONPath online evaluator tool</figcaption>

If you need to validate (and format) a JSON sample, use the [JSON Lint](https://jsonlint.com) tool.

* * *

Two resources to help you learn more:

📘 Try this step-by-step getting started tutorial: [Build Your First Automation With Okta Workflows: Notify When User Is Suspended](https://dev.to/maxkatz/build-your-first-automation-with-okta-workflows-notify-when-user-is-suspended-1l3p-temp-slug-2933517).

📺 Short how-to [Workflows videos](https://youtube.com/playlist?list=PLIid085fSVdvyK8F4xuk49EchBPmAVNHG) to help you become a better automation builder.