May I know how can go get the keys of nested JSON key value pairs of a specific value?

May I know how can go get the keys of nested JSON key value pairs of a specific value?
For example,
{“a”:[“Math”],
“b”:,
“c”:[“Science”:[“Physics”]]
}
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.

Hi @Lee_Hong_Yan ,

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 :

{
	"a": ["Math"],
	"b": [],
	"c": [{
		"Science": ["Physics"]
	}]
}

Then, we could perform the Parsing and Extract the Required Data. Follow the Steps in the Below Post but use the Below Expression :

jObj("c")(0)("Science")(0).ToString   //To Access First Element in Science

If Multiple Elements Found, We could Keep it in the below way :

jObj("c")(0)("Science").ToString

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

1 Like

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 Science, 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.