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

Community site session details

Session Id : 3Z8XBaVwCcSITLFqC260H1
Power Automate - Building Flows
Answered

Remove value in each key of JSON object

Like (0) ShareShare
ReportReport
Posted on 25 Sep 2023 14:41:04 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!

I have the same question (0)
  • Verified answer
    takolota1 Profile Picture
    4,944 Moderator on 25 Sep 2023 at 15:02:06
    Re: Remove value in each key of JSON object

    @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 25 Sep 2023 at 18:53:06
    Re: Remove value in each key of JSON object

    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,944 Moderator on 25 Sep 2023 at 19:04:50
    Re: Remove value in each key of JSON object

    @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 25 Sep 2023 at 19:11:53
    Re: Remove value in each key of JSON object

    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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Chiara Carbone – Community Spotlight

We are honored to recognize Chiara Carbone as our Community Spotlight for November…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 788 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 452 Moderator

#3
developerAJ Profile Picture

developerAJ 302

Last 30 days Overall leaderboard