Skip to main content

Create custom objects (variables) from JSON data

Power Automate Desktop can add actions from the GUI by drag and drop, but internally, a programming language called Robin is assembled.

Therefore, there are several data types for variables, and JSON data can be handled flexibly.

This time, I will explain how to create a custom object with multiple properties from JSON data.

"Convert JSON into custom objects" Action details

This time, we use an action called "Convert JSON into a custom object".

The action has the following parameters.

Parameter namevalue
JSONTarget JSON data string
Generated variablesVariables of custom objects generated

action

Implemented with copy and paste

This time, as a sample, we have prepared a flow to generate a custom object that stores two elements in the content and the elements that have an array in the content.

Copy the following code and paste it on the edit screen of Power Automate Desktop to add the target action.

Variables.ConvertJsonToCustomObject Json: $'''%'{ \'Element1\': \'Value1\', \'Element2\': \'[ArrangementValue1, ArrangementValue2]\' }'%''' CustomObject=> JsonAsCustomObject

Operate and implement Power Automate Desktop

  1. Enter "Convert JSON into custom objects" from "Search Action".

  2. Set the parameter as follows

    Parameter namevalue
    JSON%'{ \'Element 1\': \'Value 1\', \'Element 2\': \'[Arrangement value 1, array value 2]\' }'%
    Generated variables%JsonAsCustomObject%
  3. By execution, JSON data is stored in variables as a custom object.

The exception that can occur

If the specified JSON data is fraudulent, an error may occur during the analysis.

We recommend that you define block processing when an error occurs.