I was able to retrieve values for values data1, data2... using data.get function in Python.
data = json.load(file.json)print(f"##vso[task.setvariable variable=var1;isOutput=true]{data.get('A', {}).get('key1', {})}")However, I wish to make use of the same technique to retrieve the values X and Y for some particular syntax checking on my json file.
{"A": {"key1": "data1""key2": "data2","key3": "data3" },"B": {"X": {"key4": "data4", },"Y": {"key5": "data5", } }}I tried to use the following but I am also getting the keys key4 and key5 on B.
print(f"##vso[task.setvariable variable=var1;isoutput=true]{data.get('B', {})}")I only wanted to get the value of X or Y itself and not what is mapped inside.
Can anyone please help? Thanks!