Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Power Automate - Using Flows
Answered

getting json key from a given value

(0) ShareShare
ReportReport
Posted on by

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, 

  • Community Power Platform Member Profile Picture
    on at
    Re: getting json key from a given value

    Hi,

     

    Thanks for your help, it works 🙂 

  • Verified answer
    rsaikrishna Profile Picture
    3,703 on at
    Re: getting json key from a given value

    @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
    on at
    Re: getting json key from a given value

    Hi, 

     

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

     

    kind regards,  

  • rsaikrishna Profile Picture
    3,703 on at
    Re: getting json key from a given value

    @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.

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

🌸 Community Spring Festival 2025 Challenge 🌸

WIN Power Platform Community Conference 2025 tickets!

Markus Franz – Community Spotlight

We are honored to recognize Markus Franz as our April 2025 Community…

Kudos to the March Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 146,618 Most Valuable Professional

#2
RandyHayes Profile Picture

RandyHayes 76,287 Super User 2024 Season 1

#3
Pstork1 Profile Picture

Pstork1 65,957 Most Valuable Professional

Leaderboard

Featured topics

Restore a deleted flow