Press "Enter" to skip to content

How to Parse JSON in Microsoft Power Automate

There are a number of Encodian actions which return JSON data, and before that data can be consumed and used within Power Automate it must be parsed. This post aims to provide detailed guidance / detail on how this can be achieved.

This article is relevant for the following Encodian actions and the steps to parse the JSON payload can be applied to all.

The article also covers handling large and small JSON payloads, as the process required to handle differs slightly.

Parsing JSON – Small Payload

Consider the following simple Flow which is parsing a fairly small CSV file, and once parsed I’d like to add the data to a SharePoint list.

Before I can use the data returned by the ‘Parse CSV‘ action, I need to parse it by following these simple steps.

1. Execute the Flow and then select the Encodian action

2. Select the data which needs to be parsed, for this action it is the ‘CSV Data‘ property

ALERT: If the Encodian action has returned a large data set then Flow may display the result as per the image below. If this happens please review the steps within the ‘Parsing JSON – Large Payload‘ section of this post.

3. Add a ‘Parse JSON‘ action to your flow

3.a. Content: Select the relevant value from the Encodian action containing data which needs to be parsed

3.b. Click ‘Generate from sample

3.c. Copy and paste the value obtained in step #2, click ‘Done

ALERT: In some circumstances, the data returned by the Encodian action may be displayed within Power Automate as an escaped JSON string, and you may experience the following error. Please review the ‘Escape JSON‘ section of this document which explains how to resolve.

3.d. The schema has now been generated allowing you to work with the data returned by the Encodian action as dynamic data.

The screenshot below shows the parsed CSV data in Power Automate dynamic data:

Parsing JSON – Large Payload

Consider the following simple Flow which is extracting text from a large PDF file which is also returned within the payload:

NOTE: By setting the ‘Return File’ property to ‘Yes’ the Encodian action will also return the PDF file sent to the action back. We recommend this is set to ‘No’ unless explicitly required.

Before I can use the data returned by the ‘Extract Text from Regions‘ action, I need to parse it by following these simple steps.

1. Execute the Flow and then select the Encodian action and click ‘Click to download

2. This will download the raw JSON returned by the Encodian action. Your browser will govern how this will be displayed, by default Chrome will render the file as:

This can make working with the JSON pretty tricky! We’d recommend adding a JSON viewer extension such as JSON Formatter to help.

3. Locate the value which you wish to parse, in this example, we’re going to parse the ‘TextRegionResultsSimple‘ value:

4. You may have noticed that the JSON has been escaped and contains the following characters in front of the speech marks \, before the JSON can be parsed it must be unescaped, please follow the steps within the ‘Escape JSON‘ section

5. Add a ‘Parse JSON‘ action to your flow

5.a. Content: Select the relevant value from the Encodian action containing data which needs to be parsed

5.c. Copy and paste the escaped JSON value obtained in step #4, click ‘Done

5.d. The schema has now been generated allowing you to work with the data returned by the Encodian action as dynamic data.

Escape JSON

Escaping a JSON string is super simple! There are lots of online tools available such as Code Beautify

Finally

We hope this post provides the extra guidance needed to correctly parse the JSON returned by Encodian actions. If you’re struggling please raise a ticket with our support team who’ll be delighted to help

We hope you’ve found this post useful, as ever please share any feedback or comments, all welcome!

3 Comments

Leave a Reply

Your email address will not be published. Required fields are marked *