Skip to content

Create a custom object (variable) from JSON data

In Power Automate Desktop, you add actions by dragging and dropping them in the GUI, but internally, flows are built in a programming language called Robin.

Because of this, variables have several data types, and you can handle JSON data flexibly.

This article explains how to create a custom object with multiple properties from JSON data.

Details of the “Convert JSON to custom object” action

Section titled “Details of the “Convert JSON to custom object” action”

This article uses the “Convert JSON to custom object” action.

The action has the following parameters.

Parameter Value
JSON A string of the target JSON data
Variables produced The variable name of the custom object to create

action

In the image, the value of the second element (“Element2” in the code below) is specified as a string rather than an array. Specify the values as shown in the code and the table in the steps below.

As a sample, this article uses a flow that creates a custom object containing two elements: one whose content is a string, and one whose content is an array.

Copy the following code and paste it into the Power Automate Desktop flow designer to add the action.

Variables.ConvertJsonToCustomObject Json: $'''%'{ \'Element1\': \'Value1\', \'Element2\': [\'ArrayValue1\', \'ArrayValue2\'] }'%''' CustomObject=> JsonAsCustomObject
  1. In “Search actions”, type “Convert JSON to custom object”.

  2. Set the parameters as follows.

    Parameter Value
    JSON %‘{ 'Element1': 'Value1', 'Element2': ['ArrayValue1', 'ArrayValue2'] }’%
    Variables produced %JsonAsCustomObject%
  3. When you run the flow, the JSON data is stored in a variable as a custom object.

If the specified JSON data is invalid, an error (“Error parsing the JSON”) occurs during parsing.

We recommend adding error handling with an “On block error” block.