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
1
vote
1 answer

jmespath tuple from several depths

Is there a jmespath expression that will convert this: { "a": 5 , "b": [ {"c":6}, {"c":7}, {"c":8}] } into this: [ {"a":5, "c":6} , {"a":5, "c":7} , {"a":5, "c":8} ] Many thanks in advance!
Max Murphy
  • 1,701
  • 1
  • 19
  • 29
1
vote
1 answer

How to pass Ansible variables to JMESPath query?

Given the following playbook: --- - name: "foo bar" hosts: localhost connection: local gather_facts: false vars: foo: - a: aa b: bb - a: cc b: dd tasks: - debug: msg: " filter {{foo}} to…
user140547
  • 7,750
  • 3
  • 28
  • 80
1
vote
0 answers

Convert Amazon S3 object LastModified column time zone from UTC to EST

I am using a JMESPath query to filter out files from S3 objects based on LastModified date. S3 LastModified date is in UTC so I have to convert to EST. Is there a function in JSMEPath Query which can convert from UTC to EST? My query is: aws s3api…
1
vote
1 answer

Detect match failure in JMESPath

Using the Python jmespath library, how can I distinguish “matched the expression, the value is None” versus “failed to match the expression”? The jmespath.search function returns None in two distinct cases: >>> import jmespath >>> foo = {'bar':…
bignose
  • 30,281
  • 14
  • 77
  • 110
1
vote
3 answers

JMES Path / AWS - Retrieve Load Balancer name for given instance ID

I need to find the load balancer that a given EC2 instance is attached to using the AWS CLI. I have a working solution that uses jq, however I would like to avoid installing jq as a dependency and write the query in JMESPath if possible. I am stuck…
Chris
  • 390
  • 1
  • 2
  • 11
1
vote
0 answers

How to filter child nodes using jmespath?

How can I get all properties, expect those with value null using jmespath? { "foo": 10, "bar": null, "qux": ["Hello", "World"] } I'd like the result to be { "foo": 10, "qux": ["Hello", "World"] }
Arnold Daniels
  • 16,516
  • 4
  • 53
  • 82
1
vote
1 answer

find min and max by two parameters with jmespath

I have such object, I need to evaluate which is "cheapest" with jmespath { "wines": [ { "name": "b", "price1": 30, "price2": 110 }, { "name": "a", "price1": 50, "price2": 1 }, { "name":…
Jesus_Maria
  • 1,137
  • 5
  • 14
  • 24
1
vote
1 answer

JMESPath nested OR statement

I am using JMESPath in Python to efficiently parse large dictionaries/lists. I have a list of dictionaries, for each dictionary I would like to obtain a certain value or return null and put the result into a list. i.e. im selecting a field from each…
joshlk
  • 1,499
  • 3
  • 20
  • 33
1
vote
1 answer

Install jmespth-term in Mac OSx

I am unable to install jmespath-term It gives me : >> sudo pip install jmespath-term Collecting jmespath-term Could not find any downloads that satisfy the requirement jmespath-term No distributions at all found for jmespath-term Python…
sakhunzai
  • 13,900
  • 23
  • 98
  • 159
0
votes
0 answers

Python jmespath: check key and nested key in the same query?

The data is data_case_c = { "qualities": { "id": "0123456789", "key_criteria": "Target", "desired_value": {"id": "987654321", "label": "CORRECT"}, } } I want to check that key_criteria is Target. And if it is, also…
sam
  • 653
  • 9
  • 21
0
votes
2 answers

sort_by function when using AWS CLI for aws ec2 describe-security-groups

I am trying to compare 2 security groups in AWS that are in 2 different accounts, using aws ec2 describe-security-groups. Even if the security groups are exactly the same, it's impossible for me to detect that because the json response is sorted…
Zak25
  • 3
  • 3
0
votes
0 answers

Joining keys with using jmespath

I have a JSON structure as follows: { "key1": { "isSecret": null, "value": "value1" }, "key2": { "isSecret": null, "value": "value2" }, "key3": { "isSecret": null, …
user3124206
  • 375
  • 1
  • 7
  • 16
0
votes
0 answers

Concatenating JSON key, value pairs into string

I have a simple JSON object that may have the following structure: { "data":{ "k1":"v1", "k2":"v2" } } The object can contain any number of key-value pairs, but it will always be flat, meaning there are no nested objects. I'm looking…
SimonE
  • 1
0
votes
0 answers

How to get node name with JMESPath?

I have the following JSON and try to filter it with JMESPath: { "loadingExperience": { "id": "https://www.examle.com/a/", "metrics": { "CUMULATIVE_LAYOUT_SHIFT_SCORE": { "percentile": 2, "distributions": [ …
Evgeniy
  • 2,337
  • 2
  • 28
  • 68
0
votes
1 answer

How do I list property names for an object using JMESPath?

I have a situation where the objects I am querying have unknown property names, and I would like to query the property names using JMESPath. Here is an Azure CLI command and example output for it...Is there a way to get the names of the triggers…
Josh Withee
  • 9,922
  • 3
  • 44
  • 62