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
4
votes
1 answer

JSONPath or JMESPath filtering against another expression

I am struggling to find a way to filter nodes against another expression rather than a string or number. I have looked at the specs for both JSONPath and JMESPath and find a little info on the inability to do this the way I have been…
cyberwombat
  • 38,105
  • 35
  • 175
  • 251
4
votes
1 answer

What is the best way to query the following file systems for a specific file system ID?

On my AWS account I have four file systems. In creating each of these file systems, I have given each on a tag Name. I would like to use the AWS CLI to filter out the one with a specific name, and retrieve its file system id. I have already tried…
niketp
  • 409
  • 1
  • 9
  • 20
4
votes
1 answer

jmespath : getting keys with property filter

I have the following json : { "dataset_1": { "size_in_mb": 0.5, "task": "clean", "tags": ["apple", "banana", "strawberry"] }, "dataset_2": { "size_in_mb": 100, "task": "split", "tags":…
dparkar
  • 1,934
  • 2
  • 22
  • 52
4
votes
1 answer

Ansible and JMESPath, escape forward slash in a json_query

There is a simple JSON file, sample.json with the following content: { "test": { "domain": [ { "name": "cluster1" } ] } } With Ansible, I want to query over the test key, which works with the following Ansible…
Kevin C
  • 4,851
  • 8
  • 30
  • 64
4
votes
1 answer

How to jmespath.search a dictionary key using starts_with

I have a dictionary, I want to do a nested jmespath.search on the keys of the dictionary for keys that start with a specific string, but I can only seem to use the @ operator once. > d = {'foo1': 'bar', 'foo2' : 'baz'} # here's a dummy example >…
ILoveCliques
  • 135
  • 1
  • 11
4
votes
1 answer

How to take key value pairs and turn them into an array of objects using JMESPath

I'm looking to change the data structure of a 3rd party API using JMESPath and haven't been able to figure out how to take a single object of key-value pairs and restructure this to an array of objects, each containing key-value pairs. I've gone…
4
votes
2 answers

JMESPath current array index

In JMESPath with this query: people[].{"index":@.index,"name":name, "state":state.name} On this example data: { "people": [ { "name": "a", "state": {"name": "up"} }, { "name": "b", "state": {"name": "down"} …
4
votes
1 answer

AWS Route53 CLI list-resource-record-sets by Value

I need to locate a record in Route53 based on Value. My Route53 has 10,000+ records. Searching by Value for a Hosted Zone with more than 2000 records is not currently supported in the web interface. So, I must resort to using the AWS Route53 CLI's…
4
votes
1 answer

How to sort with JMESPath in ansible playbook?

I have an array returned by curl from consul during playing ansible playbook: [ { "Node": { "Node": "test-eu-west-2-staging-0" }, "Node": { "Node": "test-nyc1-staging-0" }, …
4
votes
3 answers

Filtering AWS CLI output for security groups that have specific port and IP ACLs

I'm having difficulty filtering AWS CLI describe-security-groups output Goal: Find all SGs with ingress rules on port 22 with cidr 0.0.0.0/0 Amazons' own docs provide an example, but state there's a limitation with their query in that it will first…
Ryan
  • 55
  • 1
  • 5
4
votes
1 answer

Filter JSON document in Python keeping original key path structure

I'd like to know if there is an existing Python library for filtering JSON documents by full key path that preserves the document's original structure. Here's an example: Inputs d = {"a": {"b": "c", "d": "e"}, "f": [{0: 0}, {1: 1}]} keyPaths =…
Ryan J McCall
  • 423
  • 3
  • 14
4
votes
0 answers

Getting all Object Keys from AWS Bucket after certain date?

I'm currently using the latest version (V3) of the AWS PHP SDK. I want to get all object keys from my bucket from the last X number of days. I'm trying to use the search function as described here, which uses JMESPath expressions. This comment…
ShaneOH
  • 1,454
  • 1
  • 17
  • 29
4
votes
2 answers

Complex JMESPath filter on a large JSON file

Please consider the following JSON extract (the data is much larger but this is a shorter piece of it i'm trying to get to work) jsonData = """{ "products" : { "DQ578CGN99KG6ECF" : { "sku" : "DQ578CGN99KG6ECF", "productFamily" :…
Termite
  • 76
  • 1
  • 6
3
votes
1 answer

Extracting value from nested list

The JSON I want to parse looks like this: { "results": [ [ { "field": "@logStream", "value": "i-0d41c4f2b294fae88-messages" }, { "field": "@ptr", "value":…
Phil
  • 101
  • 1
  • 5
3
votes
0 answers

JMESPath - How to check if key's value is contained in JSON object and return the value if true?

I have a contact JSON object like this: { "contactType": "Manager", "firstName": "Tom", "lastName": "Jones" } I am trying to query the object like: (contactType=='Manager') to check if the contactType is indeed Manager. My question is if the…
mortimerfreeze
  • 199
  • 1
  • 1
  • 9