jmespath / jmespath.site

The repo for the jmespath.org website.
http://jmespath.org/
Apache License 2.0
56 stars 51 forks source link

how I search an object value from given json #120

Open sanswarn opened 1 year ago

sanswarn commented 1 year ago

Hi,

The example below shows how to get "display_name" from a large file by using the multi-search function. I want to search for display_name everywhere it is declared and print the results flat.

I'm aware of one method, but it doesn't work when there are numerous large files. jq .resources[0].instances[].attributes.display_name

I want something like jq.resources[?display_name == *]

[ { "mode": "managed", "type": "oci_waf_web_app_firewall", "name": "test_web_app_firewall", "provider": "provider.oci", "instances": [ { "schema_version": 0, "attributes": { "backend_type": "LOAD_BALANCER", "compartment_id": "ocid1.compartment.oc1..aaaxukeba", "defined_tags": {}, "display_name": "FINAL_SAN_TEST1_LB", "freeform_tags": {}, "id": "ocid1.webappfirewall.oc1.pyt4hj7jznoaqa", "lifecycle_details": null, "load_balancer_id": "ocid1.loadbalancer.oc1.phx.aaaaacrxg42huyucq", "state": "ACTIVE", "system_tags": { "orcl-cloud.free-tier-retained": "false" }, "time_created": "2 +0000 UTC", "time_updated": "245:39.074 +0000 UTC", "timeouts": null, "web_app_firewall_policy_id": "ocid1.webappfirewallpolicy.oc1.phx.amaaaaaawshrd3ia2ygpfij3qni5x6jxyvsvzwvdlnju7y5yecio3avxrwfa" }, "private": "eyJlMmJmYjczMC1lY2FhLTExZTYtOGYJkZWxldGUiOjEyMDAwMDAwMDAwMDAsInVwZGF0ZSI6MTIwMDAwMDAwMDAwMH19", "dependencies": [ "oci_waf_web_app_firewall_policy." ] } ] }