Convert NLP to SQL Tools

Convert an object to an array (preview)

  • 2 minutes to read

Template ID: convertobjecttoarray

Converts a JSON object in the request or response body to an array. This template is available in Power Apps and Power Automate.

First, enter the path to the parent object or collection. Then enter the property sub-path of the parent element in which the array is located. Next, you provide a property name for the key of each child object and a new property name for the properties within each child object. Finally, enter the path in which the new object property will be written.

Some things to keep in mind:

  • You can leave the subpath blank if the parent is the array you want to transform.
  • To overwrite the existing array, the path would be the parent path and property sub-path previously specified.
  • To keep the specified object key as a property within the new object, set the Keep key option to true (this is the default if left blank). Otherwise set the option to "false".

Examples

Let's look at some examples that use the following parameters.

Example 1

JSON input:

Input parameterscolour
propertyParentPath@body()
propertySubPathpeopleObject
newPropertyPath@body (). peopleArray
keyNameName of the dataflow
valueNameinformation

JSON output:

Example # 2

JSON input

Input parameterscolour
propertyParentPath@body (). sets
propertySubPathpeople
newPropertyPath@item (). people
keyNameName of the dataflow
valueNameinformation

JSON output:

Note that since the parent is a collection, the transform is applied to each subpath.

Example of an open source connector

We have an instance of this template that is used in our open source connectors repository.

Interconnectsscenario
PlannerTransform a reference object into an array of references in the response for the Get Task Details action.

Input parameters

Name of the dataflowkeyRequiredArtdescription
x-ms-apimTemplateParameter.propertyParentPathYesStringPath to the object or collection.
x-ms-apimTemplateParameter.propertySubPathStringProperty subpath within the object or collection.
x-ms-apimTemplateParameter.newPropertyPathYesStringPath of the new object.
x-ms-apimTemplateParameter.keyNameStringProperty name for the key.
x-ms-apimTemplateParameter.valueNameStringProperty name for the value.
x-ms-apimTemplate-policySectionYesenumerationSpecifies when this policy should run
- Request: The policy template is executed before the request is sent to the backend API.
- Response: The policy is executed after receiving the response from the backend API.
x-ms-apimTemplate-operationNameArrayThe policy runs on the selected list of actions and triggers. If no operation is selected, this policy applies to all operations.