Questions tagged [jmespath]

JMESPath (JSON Matching Expression paths) is a query language for JSON. JMESPath allows you to extract elements from a JSON document. It also allows you to directly transform the queried elements.

JMESPath (JSON Matching Expression Paths) is a query language for .

In addition to allowing you to extract elements from a JSON document, it also allows you to transform the queried elements.

In other words: JMESPath is to JSON what is to .

For questions about JSON itself, please use the tag.

Useful Links:

495 questions
2
votes
2 answers

AWS CLI: Describe Network ACLs

I am having a bit of an issue with this command. I am trying to list out only the egress ACL rules, and just the rule number. So this is my command: aws ec2 describe-network-acls --network-acl-ids acl-c324a5a4 --output text --query…
Felipe Caldas
  • 2,492
  • 3
  • 36
  • 55
2
votes
1 answer

How to do "object projection" filter in JMESpath, or how to filter a list?

Given the following JSON: { "apps": { "foo": { "version": "1" }, "bar": { "version": "2" } } } I would like to get the number of apps which have a version 2. An object projection apps.*.version gives a list, [ …
user140547
  • 7,750
  • 3
  • 28
  • 80
2
votes
2 answers

query on nested python objects

I have some objects structure created with YAML. Inside YAML many tags are used. So the document contains not only builtin types but also some objects created from registered constructors. I need to check them by some patterns. So far I've tried…
Ev_genus
  • 135
  • 11
2
votes
1 answer

AWS RDS: how to get latest snapshot with boto3 and jmespath?

Here is what I tried: #!/usr/bin/env python3 import boto3 import jmespath from datetime import datetime, timedelta now = datetime.utcnow() yesterday = now - timedelta(days=1) boto3.setup_default_session(profile_name='profilename') rds_client =…
ERIK_SON
  • 379
  • 5
  • 16
1
vote
1 answer

Python jmespath: How to return value inside nested dict if outer dict key matches criteria

The data is data_case_c = { "qualities": { "id": "0123456789", "key_criteria": "Target", "desired_value": {"id": "987654321", "label": "CORRECT"}, } } I want check that key_criteria is Target. And if it is, return…
sam
  • 653
  • 9
  • 21
1
vote
1 answer

Does JMESPath have an 'in' like operator, that will be true if a key's value is present in an array of strings?

Does JMESPath have an 'in' like operator, that will be true if a key's value is present in an array of strings? Given the following snippet of data, (assume the number of items is much larger, and I want to select a few) [ { "object": { …
J. M. Becker
  • 2,755
  • 30
  • 32
1
vote
2 answers

What governs columns rendered in Azure CLI determined for output table

When I go like this, I get a nice table view, which (awesomely too) pretty much always contains just what I need. az ad app list --all --output table Now, as a true developer (read: problem solver), while totally satisfied, I just had to find me a…
Konrad Viltersten
  • 36,151
  • 76
  • 250
  • 438
1
vote
1 answer

JMESPath query with CloudCustodian filter Key for ec2 ami

I would like to find and stop, using cloudcustodian, all ec2s that are running an ami older than a certain date and that have a certain tag. The tags on such ami would look like "Tags": [ { "Key": "tag-1", "Value": "value-1" …
user2175783
  • 1,291
  • 1
  • 12
  • 28
1
vote
0 answers

How can I use a JMESPath query to filter on strings ending with timestamp

How can I use a JMESPath query to filter a property Name which starts with abc, and ends with a timestamp in the format YYYYMMDD-HH, for example: abc-20230913-11. I know how to filter a string using starts_with and ends_with, but I am not sure how…
user389955
  • 9,605
  • 14
  • 56
  • 98
1
vote
2 answers

How can I get a list of keys and just the first level (sub keys) from json using ansible?

I am stuck in this piece of work.. i have tried so many things but i think i have gone far into the abyss that i cant think outside now. I have a a fact with the list: set_fact is food_sub_list { "food_a": { "list_veg": { …
spiceitup
  • 132
  • 10
1
vote
1 answer

JMES to get only matching items

I am trying to get the JMES query to give me only items which have a Tag with Name matching Value of match. So far I have GlobalNetworks[].[Tags[?Key==Name && Value==match]] but that gives me the non-matching one too. I also only want the…
Ruskin
  • 1,504
  • 13
  • 25
1
vote
2 answers

Python jmespath expression to return value if is is a string, if it is an array to a ',' join on it

I have an attribute on a dictionary that I want to extract as a string. It can either come in as a string, or an array of strings. If it is an array, I would like to join all the elements together using , as the delimiter. What would that jmespath…
Jasonca1
  • 4,848
  • 6
  • 25
  • 42
1
vote
1 answer

Invalid JMES search result type, only string is allowed

I am trying to mount a Kubernetes secret via a kubernetes_manifest like this, however, port is a number 5342 resource "kubernetes_manifest" "test" { manifest = { "apiVersion" = "secrets-store.csi.x-k8s.io/v1alpha1" "kind" =…
jipot
  • 304
  • 3
  • 13
  • 34
1
vote
2 answers

Filter JSON field from file

I have a JSON file with some data on it, like the below one: { "84d0da32-c945-9844-86cc-4b4bd6100dc5": { "UUID": "84d0da32-c945-9844-86cc-4b4bd6100dc5", "GroupName": "TEST1", "EntryTitle": "host1", "Username":…
scapy
  • 110
  • 5
1
vote
1 answer

Ansible filter service status results

I want to filter service statuses of specific services on my Linux nodes, displaying this to whoever is running the playbook. I'm able to bring back all services but this is far too much especially as it will be running on multiple servers. I only…