Powerautomate Json - Convert Array of Object to String
So, I Have a Json Object That Contains an Array of Users Who Are Members of a Group. I Would Like to Take All of Those Users and Squish Them into One Nice...
So, I have a JSON object that contains an array of users who are members of a group. I would like to take all of those users and squish them into one nice string and put that string into a sharepoint list.
I THINK I would use compose, but honestly I've never used it before and I have no idea how. Really, the hope is to convert this:
{
"@odata.context": "",
"value": [
{
"@odata.type": "#microsoft.graph.user",
"id": "e3eec502-97a5-47cc-ae81-82c34c4e9b4a",
"businessPhones": [],
"displayName": "User one",
"givenName": "User1",
"jobTitle": null,
"mail": "[email protected]",
"mobilePhone": null,
"officeLocation": null,
"preferredLanguage": null,
"surname": "one",
"userPrincipalName": "[email protected]"
},
{
"@odata.type": "#microsoft.graph.user",
"id": "ab02d0c4-5770-4a54-95ec-200fb55dfd27",
"businessPhones": [],
"displayName": "User two",
"givenName": "User2",
"jobTitle": null,
"mail": "[email protected]",
"mobilePhone": null,
"officeLocation": null,
"preferredLanguage": null,
"surname": "two",
"userPrincipalName": "[email protected]"
},
{
"@odata.type": "#microsoft.graph.user",
"id": "15610147-ca81-47c3-bd34-ad046ff9ac46",
"businessPhones": [],
"displayName": "User three",
"givenName": "User3",
"jobTitle": null,
"mail": null,
"mobilePhone": null,
"officeLocation": null,
"preferredLanguage": null,
"surname": "three",
"userPrincipalName": "[email protected]"
}
]
}
To this
User one, User two, User three
Any ideas or resources I can check out? Thanks.
2 Answers
This can be achieved using the Parse JSON, Select and Join actions.
The finished flow will be trigger by a button and contain the following actions:
- Initialize variable - Initialize a variable with the data we want to manipulate
- Parse JSON - Assigns a schema to the data allowing us to more easily access the array
- Select - Converts the object array into a string array
- Join - Concatenates all the items within the string array
and look like this:
Each action needs to be implemented as follows:
Must Read
1. Initialize variable
First add an initialize variable action with the following values:- Name: data
- Value: The JSON you want to process (as noted in the answer the "@" characters should be removed)