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

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, 

Categories:
I have the same question (0)
  • rsaikrishna Profile Picture
    3,703 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
    on at

    Hi, 

     

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

     

    kind regards,  

  • Verified answer
    rsaikrishna Profile Picture
    3,703 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
    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

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 522 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 364 Moderator

#3
abm abm Profile Picture

abm abm 243 Most Valuable Professional

Last 30 days Overall leaderboard