Quantcast
Channel: Active questions tagged jq - Stack Overflow
Viewing all articles
Browse latest Browse all 582

How to filter only the object name using jq/jmespath?

$
0
0

I have the following json:

{"hostNamesDisabled": false,"hostingEnvironmentProfile": null,"httpsOnly": true,"hyperV": false,"identity": {"principalId": null,"tenantId": null,"type": "UserAssigned","userAssignedIdentities": {"<random_object_name>": {"clientId": "xxxx","principalId": "xxxx"        }    }},"inProgressOperationId": null,"isDefaultContainer": null

}

With jq, I can easily filter keys like:

$ jq -r '.httpsOnly'true

or

$ jq -r '.identity.principalIdnull

and retrieve their respective values, so that I could use them in a shell script as variables.

Question is: how to filter the identity.userAssignedIdentities object to obtain only the <random_object_name> name/content, like so:

$ jq -r '.identity.userAssignedIdentities.???'<random_object_name>

but not the remaining key-value pairs?


Viewing all articles
Browse latest Browse all 582

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>