Getting certain lines from a file

I have a text file shown below and I am trying to get the OS value of server XYZ

[
{
"Identity": {
"Name": "BigFix Internal Relay"
},
"Server": {
"Name": "ABC"
},
"OS": "Win 2022"
},
{
"Identity": {
"Name": "BigFix DMZ Relay"
},
"Server": {
"Name": "XYZ"
},
"OS": "Win 2019"
}
]

I tried using below relevance but it is also taking the information of the other server. I know there needs more modification on this but can you check what would be the efficient way to achieve it?

lines whose ((it contains "XYZ") or (it contains "OS") of file "c:\temp\test.txt"

Thanks.

The ‘whose’ clause feels a bit clunky, but I came up with:

values of keys "OS" of elements whose (exists keys "Server" whose(exists keys "Name" whose (value of it as string = "ABC") of values of it) of it) of jsons of file "c:\trn\comps.json"

suggestions for improvement are welcome :slight_smile:

3 Likes

This is exactly what I need :slight_smile:
Thank you.