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

Can I do multiple search strings in a single JMESPath search?

I want to be able to perform multiple searches inside a JSON using JMESPath with JavaScript, so I don't have to iterate over the large object for each JMESPath search string I need to perform. I have this example object (let's call it arrayItem): { …
nxtlvl
  • 21
  • 3
1
vote
1 answer

JMESPath query with boolean values?

I'm trying to develop the expression to query Route53 and pull out the ID of our private zone. Problem is the query string returns an empty array. Base data below — running aws route53 list-hosted-zones: { "HostedZones": [ { …
OPP
  • 43
  • 5
1
vote
2 answers

Multiple conditions in JMESPath query does not give any results

I am trying to query the following Infoblox data with Ansible and JMESPath json_query: { "ip_records.json": { "result": [ { "_ref": "fixedaddress/blabla", "ipv4addr": "10.10.10.10", …
Marc
  • 41
  • 4
1
vote
1 answer

Set null value in ternary operator in JMESPath?

Is there a way to set a value to null with JMESPath? In my example, the value should be set to null if qux_1 is not null and else the value should be set to the value of baz. I thought the ternary operator could be read as if else condition but null…
Blob
  • 371
  • 1
  • 9
1
vote
1 answer

Return integer or string instead of None from a JMESPath query

Is there a way to return an integer or a string instead of None? I know that I can do an additional check like: item = {"SX": {"BX": 1}} value = jmespath.search("SX.BX", item) if jmespath.search("SX.BX", item) else 0 but the condition is very long…
alek vertysh
  • 187
  • 4
  • 10
1
vote
1 answer

List all AWS Elasticache snapshots taken after a specified date

I am trying to write a query in AWS CLI which will provide with the elasticache snapshots names older than a specific creation date. I tried with a JMESPath query like: aws elasticache describe-snapshots \ --region ap-southeast-1 \ …
1
vote
1 answer

Split a JSON string value using JMESPath

I have a payload in a format similar to below: { "year": "2022", "cycle": "Aug", "origin": { "file_location": "GDT Post-Distribution Manifest/Italy/Rome/2022/Aug/Italy Rome_202208241528.xlsx", "protocol": "s3:" } } I want to…
user2772056
  • 135
  • 1
  • 2
  • 9
1
vote
1 answer

Unable to filter for multiple features with JMESPath

My data looks as follows. How come I am able to filter for one word using contains but not a list of words I wish to filter for? both queries should produce the same output import jmespath data = {'collection': {'items': {'word':…
Blob
  • 371
  • 1
  • 9
1
vote
1 answer

Filtering JSON data with equality operator

Given the query @.records[*].issues[].[type, message] on the JSON { "records":[ { "id":"db7bb828-60e2-5fa8-048c-06542abd98d2", "parentId":"3dc8fd7e-4368-5a92-293e-d53cefc8c4b3", "type":"Task", …
eliassal
  • 343
  • 5
  • 20
1
vote
1 answer

Is there a way to query a nested value in jmespath without having to provide the path?

I'm trying to find a way to get all the names from the people list, without have to specify the path. Is there a way to do this in JMESPath. i.e without having to step down multiple paths. I.e.: I want to grab a list of all the names. { "country":…
felix001
  • 15,341
  • 32
  • 94
  • 121
1
vote
2 answers

JMESPath to flatten complicated query array results

Given the JSON { "Reservations": [ { "Groups": [], "Instances": [ { "AmiLaunchIndex": 0, "ImageId": "ami-0abcdef1234567890", "InstanceId": "i-1234567890abcdef0", "InstanceType":…
xpt
  • 20,363
  • 37
  • 127
  • 216
1
vote
1 answer

JMESPath - Ansible-AWX - JSON

I have the following json where i wish to extract the name based on externalId (2720135) { "data": [ { "id": "f15073f7-c934-479f-bed9-07b6c3402b60", "name": "360 Index", "description": "360 Index", "displayName":…
Kevin
  • 143
  • 1
  • 8
1
vote
2 answers

JMESPath filter for elements with nested values starting with certain string

I have the following JSON structure: [ { "stack": [ "datasync" ], "env": [ "dev", "test" ], "runOnBranch": [ "feature/", "bugfix/", …
WolfgangM
  • 243
  • 2
  • 14
1
vote
1 answer

Got out list of values, How do i select first 10 or first 20 or first 30 only

[ "dltpglci553i7mxg3vbkml7ns46p57bbnsn", "zpxtlv6s37frl4645n3pfcbg3pblrfgmjzvd5n7w", "wfv4mrzqnq2nq44xbsn35iiqnindixct2kspwfdq", "p2vgqnvwwnwdxmrjk6lzk6x6wfwinjdc4tbgq", "ttg3i44dxflbnwlbpqvmm22kvbkgcjmzl4fjrznipgkcr", "qqc7lficx3bcxrfrkt4dnrrb4m7m2i…
Harry
  • 91
  • 7
1
vote
1 answer

Jsonpath or jmespath to get just id if created

{ "data": [ { "compartment-id": "ocid1.compartment.oc1..42949232syq", "defined-tags": { "Oracle-Tags": { "CreatedBy": "svc-1", "CreatedOn": "2022-08-19T05:48:06.460Z" } }, …
Harry
  • 91
  • 7