Convert String to JSON using Power Automate Microsoft Flow

Introduction

This article shows how to convert a string to JSON. The JSON Expression can be used to convert a string to JSON quickly.

We can also use the Parse JSON Data Operation by specifying the schema.

Step 1. Enter your username and password to log in to the necessary Power Apps environment at make.powerapps.com, then click on Flows on the left-hand side, as shown in the illustration below.

Cloud Flows

Step 2. After completing step 1, select New Flow, Instant Flow, and then Manually trigger a flow under the option Choose how to trigger the flow. Then, click Create, as shown in the below diagram.

Trigger the flow

Step 3. Create a string variable and set its initial value to the JSON object. I've already initialized it. You might obtain this value from the API response during complex flows.

Trigger flow

Step 4. By choosing to compose from the Data Operation, add a step.

Data Operation

Step 5. Add the following expression to the inputs and Click OK.

json(variables('JSONString'))

String JSON

Step 6. As shown below, save the flow and manually test the flow.

Test Flow

Step 7. Clicking Done, as shown in the figure below, after clicking Run Flow, will bring up a list of options below the screen.

Run Flow

Step 8. As we can see, the String is converted to JSON by using the JSON Expression

Outputs

Step 9. Create the Parse JSON Data Operation Step to convert the String Variable to JSON.

Parse JSON

Step 10. Add the JSONString Variable to Content in Parse JSON Data Operation from the Dynamic Content as shown in the screenshot below.

JSON String

Step 11. Select the Sample JSON Format you want to convert and click the Generate from Schema button on the Parse JSON Step.

JSON Played

Step 12. Repeat Steps 6 & and Step 7 then we can see that String is converted to JSON by using the Parse JSON Data Operation.

JSON Parse

Step 13. Add Compose Step and choose the necessary data from the Dynamic content Under Parse JSON to read the Parsed JSON Data.

JSON Data

Step 14. Repeat Steps 6 & and Step 7 then we can read JSON Data.

Read JSON Data

Summary

In this article, I discussed how we can Convert the String Value to JSON in 2 different ways one is JSON Expression, and the other is Parse JSON Data Operation and Reading the JSON Data.


Similar Articles