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

Announcements

News and Announcements icon
Community site session details

Community site session details

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

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,980 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,980 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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the March Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
Haque Profile Picture

Haque 594

#2
Valantis Profile Picture

Valantis 328

#3
David_MA Profile Picture

David_MA 281 Super User 2026 Season 1

Last 30 days Overall leaderboard