May I know how can go get the keys of nested JSON key value pairs of a specific value?
I wish to get output something like,
[“c”][“Science”] or similar so that I can automate the clicking of respective link to go to Physics page.
Thanks in advance.
Could You Check the Json Data Provided. It seems to be an Invalid Json.
If the Input Data was Expected to be in the below Way :
Then, we could perform the Parsing and Extract the Required Data. Follow the Steps in the Below Post but use the Below Expression :
Give a Try on the below Steps :
Use Deserialize Json Activity with TypeArgument as JsonObject and input as the Output from the API, Let the output be jObj
Next, we could get all the description field values from the textAnnotations JsonArray using the following Expression :
This provide us all the description field values present in the textAnnotations …
jObj("c")(0)("Science")(0).ToString //To Access First Element in Science
If Multiple Elements Found, We could Keep it in the below way :
We might need to do String Operations to get the Output as required.
Let us know if there is any change in the Input data and also Check if the above method works
What if it is user specified, like for example it is not necessary Physics for every case, it may be Math, is there a dynamic way to get all the parent key?
@Lee_Hong_Yan Here, we access the Contents of
Physics is the Resultant Content. If there are other values within the Science JArray, it would also be retrieved.
However, Do Perform a Testing with different data that you have, we can formulate what we need to accordingly if it doesn’t satisfy any of the sample data.
But the problem I faced is the json is deeply nested and for all the cases, the targetted child(value) is following different nested path of the json(not predictable). Is there a way to get the key of the deeply nested value bottom up to the upmost parent?
@Lee_Hong_Yan It would be more clear, if we could get the Input data, and also the Expected Output data from it.
This way we could avoid any other temporary outputs and stick to the final Output Generation.