Convert Delimited String Into Array Of Objects(Preview)
Template ID: stringtoarray
Converts a delimited string to an array of JSON objects with each value being assigned to the user-specified property within each corresponding object. This template is available in Power Apps and Power Automate.
In this article
To start, specify the path to the parent object or collection and the property subpath of the delimited string within the parent. Next, specify the delimiters to parse, and the property name of each child object that the string will be converted into. Finally, specify the path where the array will be written to. To overwrite the existing string, the path would be the previously specified parent path and property subpath.
This template does not support the transformation to an array of strings ("3:0"
→ ["3", "0"]
). The choice of converting into an array of objects instead was made to optimize for
the scenarios we typically see in connectors. Hence specifying the child property name is a requirement.
Examples
Example 1
Input JSON:
{
"peopleObject":{
"XYZ":{
"Age": "3;0"
},
"ABC":{
"Age": "23;45"
}
}
}
Input Parameter | Value |
propertyParentPath | @body() |
propertySubPath | peopleObject.XYZ.Age |
delimiterList | ; |
childPropertyName | AgeW |
newPropertyPath | @body.peopleObject.XYZ.Age |
Output JSON:
{
"peopleObject":{
"XYZ":{
"Age":[
{
"AgeW": "3"
},
{
"AgeW": "0"
}
]
},
"ABC":{
"Age": "23;45"
}
}
}
Examples from open-sourced connectors
We have one instance of this template being used in our open-sourced connectors repository.
Connector | Scenario | |
Planner | Convert strings of userIds that are seperated by a semicolon into an array |
Input Parameters
Name | Key | Required | Type | Description |
---|---|---|---|---|
Target object or collection path |
x-ms-apimTemplateParameter.propertyParentPath | True | String | Path to the object or collection which contains the property. |
Property subpath |
x-ms-apimTemplateParameter.propertySubPath | String | Property subpath within the object or collection. | |
Delimiter list |
x-ms-apimTemplateParameter.delimiterList | True | String | List of delimiters. |
Object child-property name |
x-ms-apimTemplateParameter.childPropertyName | True | String | Name of the property within each object that should contain the array item value. |
Path of the new property |
x-ms-apimTemplateParameter.newPropertyPath | True | String | Path of the new property. |
Run policy on |
x-ms-apimTemplate-policySection | True | Enum | Specifies when to run this policy - Request : Policy template will run before request is sent to the backend API. - Response : Policy will run after receiving response from the backend API. |
Operations |
x-ms-apimTemplate-operationName | Array | List of actions and triggers to which the policy will apply to. If no operation is selected, this policy will apply to all operations. |