web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Remove value in each k...
Power Automate
Unanswered

Remove value in each key of JSON object

(0) ShareShare
ReportReport
Posted on by 28

Hi all - i am looking to remove any spaces that may be a value in a JSON object.  Would anyone know the most efficient way to do this without having to declare each key in a Compose statement?  Perhaps by looping through each key?  Thanks!

Categories:
I have the same question (0)
  • Verified answer
    takolota1 Profile Picture
    4,974 Moderator on at

    @PR001 

     

    You should be able to do this is one action that runs in under a second.

     

    Use a Select action on the JSON array.

    Switch the Select Map input to a single input box instead of a table.

    Use a setProperty( ) expression on the item() https://learn.microsoft.com/en-us/azure/logic-apps/workflow-definition-language-functions-reference#setProperty

    Use the name of the key for the property name, then for the value use a replace(item()?[‘InsertKeyName’], ‘ ‘, ‘’)

     

    The Select has an internal looping that will go over each object in the JSON array & set that key property value to the new value without spaces.

  • PR001 Profile Picture
    28 on at

    Thank you Takolota.   What if i have to replace the value for all the keys in the JSON array?  Specifically, I would like to remove all special characters from the JSON array.  Thanks again!

  • Verified answer
    takolota1 Profile Picture
    4,974 Moderator on at

    @PR001 

     

    For all keys/values, as long as the special characters do not include the JSON array structure characters like “ , : { } [ ] then I would just use a single Compose &…

    Use string( ) on the entire JSON array

    Outside the string expression add multiple replace( ) expressions, one for each special character to remove.

    Outside all the replace( ) expressions use a json( ) expression to return it back from a string to JSON.

  • PR001 Profile Picture
    28 on at

    Great makes sense.  Thank you sir!

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 538 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 405 Moderator

#3
abm abm Profile Picture

abm abm 252 Most Valuable Professional

Last 30 days Overall leaderboard