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 / getting json key from ...
Power Automate
Answered

getting json key from a given value

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

Hi all, 

 

I'm stucked with this issue : 

I have a json object like that : 

{
 "key1": "", 
 "key2": "1/10", 
 "key3": "1/1,1/2,1/3,1/5", 
 "key4": "1/24", 
 "keyX": "1/1,1/2,1/3,1/5,1/4" 
 }

 

I want to return the key name for a given value. 

For example, if I know a value (eg. 1/24), I want to get the key name (eg. key4). 

 

the key name are not always the same, so I can't use the parse json tool.

 

  1. Do you knows if it possible? 
  2. if yes, what is the best way to achieve that? 

 

best regards, 

Categories:
I have the same question (0)
  • rsaikrishna Profile Picture
    3,703 Microsoft Employee on at

    @Anonymous 

     

    You mentioned about an example 1/24. It seems to be unique.

     

    But, for examples: 1/2 or 1/3 or few other values, they are associated with multiple keys. In these cases, are you expecting to have all the key names which matches the value?

     

    Regards

    Krishna Rachakonda

    If this reply helped you to solve the issue, please mark the post as Accepted SolutionMarking this post as Accepted Solution, will help many other users to use this post to solve same or similar issue without re-posting the issue in the group. Saves a lot of time for everyone.
  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Hi, 

     

    Correct, I need to have all key names that match the value.

     

    kind regards,  

  • Verified answer
    rsaikrishna Profile Picture
    3,703 Microsoft Employee on at

    @Anonymous 

     

    With JSON parsing, i do not see a way to get the desired result. I am curious to see if anyone has ideas.

     

    By using String manipulation actions, you can get to the desired result.

     

    Created a sample to get the desired result:

     

    1.JPG

    2.JPG

     

    Expression in Compose1:
    trim(replace(replace(variables('varJsonString'),'{',''),'}',''))

     

    3.JPG

     

    Expression in Compose2:
    split(outputs('Compose_1'),'",')

     

    4.JPG

     

    Expression in above Compose action:
    concat(items('Apply_to_each'),'"')

     

    5.JPG

     

    Expressions in Condition:
    
    1st Concat expression:
    concat(variables('varInputValue'),',')
    
    2nd Concat expression:
    concat(variables('varInputValue'),'"')
    
    In Yes block, Expression in Compose 2:
    trim(replace(substring(outputs('Compose'),0,indexOf(outputs('Compose'),':')),'"',''))

     

    Append to array variable: Collecting the matching keys into array

    Writing the output in Compose 4

     

     

    6.JPG

     

    RESULT:

     

    7.JPG

     

    I hope this will be helpful to resolve your issue.

     

    Please mark the reply as Accepted Solution, if my reply is helpful. It will also help other users to consider it as a reference.

     

    NOTE: The above solution can be written much better if we keep performance in view. Give a try.

     

    Regards

    Krishna Rachakonda

    If this reply helped you to solve the issue, please mark the post as Accepted SolutionMarking this post as Accepted Solution, will help many other users to use this post to solve same or similar issue without re-posting the issue in the group. Saves a lot of time for everyone.
  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Hi,

     

    Thanks for your help, it works 🙂 

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 April Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
Vish WR Profile Picture

Vish WR 1,027

#2
Valantis Profile Picture

Valantis 815

#3
Haque Profile Picture

Haque 630

Last 30 days Overall leaderboard