Power Automate: skip the Parse JSON action to reference data

Why?

Let me emphasize that using the Parse JSON action (as explained in this great blog post of Luise Freese: How to use Parse JSON action in Power Automate) is always the way to go when you are starting with Power Automate. Especially if you want to have properties of your JSON ouput to show up as Dynamic Content in the rest of your Flow.

However the Parse JSON action is very picky… The action will fail if a property is missing, a new property is added later on or an existing property is giving back a different type of data. In short: any schema change not being updated in the settings of the action can cause a ❌ “ValidationFailed error” ❌. Such an error will stop the Flow because the schema validation failed:

Parse JSON action failing because of Invalid type

As long as you remind to also update the Parse JSON action schema, it will continue working fine.
But in my case, I wanted to know if Power Automate could skip the Parse JSON action 🤓

What?

In this blog post, I can show you a way to skip the Parse JSON action and reference a property of an action with JSON output directly. This way, we can have one action less (#LessUsage #LessAPIcalls) and thus one action less that could fail (#Lean #LessActionsLessRisks).

How?

Let’s first have a look at a simple JSON object:

A simple JSON Object with two properties

The output of this Compose action will be this JSON output:

{
  "Property Product": "Product A",
  "Property Product Category": "Product Category 1"
}

I am using a Compose action to give JSON output, but in most cases JSON output will come from actions connected to a data source. In some types of actions unfortunately Power Automate does not create Dynamic Content. In these cases, the properties of these action do not show up in the Dynamic Content Panel for the rest of your Flow. When using the Parse JSON action on the output of such an action:

Parse JSON action with the Scheme generated from sample coming from the previous action output

we can force the rest of the Flow to show us these properties in the Dynamic Content Panel. Making it easy for us to reference these properties. The Content input of the Parse JSON action will be the output of the Compose – SimpleJSONObject action:

@{outputs('Compose_-_SimpleJSONObject')}

Thanks to the Parse JSON – SimpleJSONObject action, we can (from this action on) use the properties defined in its Schema as Dynamic Content:

The expression of this reference would look like:

@{body('Parse_JSON_-_SimpleJSONObject')?['Property Product Category']}

In my first screenshot, you can see the action failing. It failed because the schema was expecting a string, while the Content input was giving an integer number. This was because I changed the JSON object temporarily 😈 to:

{
  "Property Product": "Product A",
  "Property Product Category": 1
}

1) We can also reference the property of the first action Compose – SimpleJSONObject action directly. We can use an expression like:

@{outputs('Compose_-_SimpleJSONObject')?['Property Product Category']}

Power Automate can thus skip the Parse JSON action. Even without this parsing, we can reference the property of any action with a JSON output:

No Parse JSON action needed! 😎

5 thoughts on “Power Automate: skip the Parse JSON action to reference data

  1. Do I need the Parse JSON action or not. When i look at your images it looks like I still need the Parse JSON action?
    the json output normally looks like this

    “body”: {
    “dateTimeDigitized”: “2022:10:31 11:06:45”,
    “dateTimeOriginal”: “2022:10:31 11:06:45”,

    1. Hi Matthias,
      This topic is on how to skip / not need the Parse JSON action so it shows on how to not need it.
      In my example you can see that @{outputs(‘Compose_-_SimpleJSONObject’)?[‘Property Product Category’]} references the [‘Property Product Category’] property of the JSON object coming from the Compose Action.

      Your JSON output could reference the [‘dateTimeDigitized’] property like: @{outputs(‘HERE_GOES_YOUR_FLOW_ACTION_NAME_DEPENDING_ON_TYPE_OF_ACTION’)?[‘dateTimeDigitized’]}. Depending on the type of action and the response returned (a single object versus a multi-object array) it could also be:
      @{body(‘HERE_GOES_YOUR_FLOW_ACTION_NAME_DEPENDING_ON_TYPE_OF_ACTION’)?[‘dateTimeDigitized’]}. Arrays will need more complexity because referencing a single object in a response with multiple objects will require you to determine which object. For example the first one: @{first(body(‘HERE_GOES_YOUR_FLOW_ACTION_NAME_DEPENDING_ON_TYPE_OF_ACTION’))?[‘dateTimeDigitized’]} but that all depends on the schema of your ouput…

  2. I get the error, “Property selection is not supported on values of type ‘String’.” when I try this. Any idea what I’m doing wrong?

Leave a comment