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
3
votes
2 answers

How to sort JSON output from AWS CLI using JMESPath

I try to sort this output from AWS CLI by ImageId, and I executed command below. aws ec2 describe-images --profile xxxxxxxxxx \ --filter Name=tag:Name,Values=Backup*some-string* \ --query "Images[*].[Tags[?Key=='Name'].Value[]|[0],ImageId]" output…
Rohan Kishibe
  • 617
  • 2
  • 10
  • 25
3
votes
3 answers

Filtering with Azure CLI and JMESPath for network vnet peering list

I'm using the Azure CLI to get a list of vnet peerings: az network vnet peering list. This returns json in the following structure: [ { ... "name": "prefix1-name", ... }, { ... "name": "prefix2-name", ... } ] I am…
rcarrington
  • 1,485
  • 2
  • 12
  • 23
3
votes
1 answer

How do I escape the '@' symbol inside a string literal key for a jmespath search query

I am using jmespath to search a snippet of JSON, and one of the JSON keys contains an '@' symbol. Since the '@' symbol is a reserved character, jmespath chokes. I have tried a number of things to escape the '@' symbol unsuccessfully. How do I…
3
votes
1 answer

Is there any method by which a parent key can be accessed based on a condition on a key in the child object in jmespath?

I have been working with parsing a big json file. I am unable to use jq as its been tested in our systems where it takes comparitively good amount of time for completion of parsing. We have been using Jmespath as it has been tested fine with json…
ram
  • 133
  • 6
3
votes
2 answers

Is there a query language for JSON which allow access to parent node and has multiselect?

There are many query languages for JSON, such as JMES Path and JSON Path, but none of the ones I've found interest me, e.g. JSON Path doesn't allow multiselect query (I can't return a list with different type element [car, plane, boat]) and JMES…
bosskay972
  • 890
  • 1
  • 6
  • 27
3
votes
1 answer

Does JMESPath have an identity function?

In the jq filtering language the . filter expression simply returns the input JSON unaltered (except for pretty printing). E.g. $ echo '{"foo": true, "bar": 42}' | jq '.' { "foo": true, "bar": 42 } Does JMESPath have a similar expression (aka…
Alex Willmer
  • 491
  • 4
  • 14
3
votes
3 answers

How to check an array inside json data is empty using jmespath?

I have json data as below: [ { "id": "i_1", "name": "abc", "address": [ { "city": [ "city1", "city2" ] }, { "city": [ "city1", "city2" ] } …
Monarth Sarvaiya
  • 1,041
  • 8
  • 20
3
votes
1 answer

Sum values of JSON array using JMESPath

I am trying to use the sum function of JMESPath but having some trouble. I managed to figure out how to use the search function with multiple conditions. This statement: var x = search(myData, "Account[].Details[? Year=='2018' &&…
DanielAttard
  • 3,467
  • 9
  • 55
  • 104
3
votes
1 answer

JMESpath expression to filter object by property and return list of object names having this property set

Is it possible to write JMESPath expression to return a list of object names where a specific subproperty value is set? In the example below I'd like to get a list of all hostsnames where fileexists.stat.exists is set to true. My goal is to use…
Ilmar Kerm
  • 31
  • 1
  • 3
3
votes
1 answer

Using jmespath to concat two fields of json

I have this inputJson: [{"firstName": "Kancha", "lastName": "Cheena"}, {"firstName": "Harley", "lastName": "Quinn"}] Expected output: [{"fname":"Kancha", "value": "Kancha Cheena"}, {"fname":"Harley", "value": "Harley Quinn"}] I am using an…
Ankit Gupta
  • 275
  • 3
  • 12
3
votes
2 answers

Ansible json_query outputs list when using a filter expression

I'm running ansible 2.4.0 on OSX. The following playbook... --- - hosts: localhost connection: local gather_facts: False vars: data: - name: thing1 desc: I am thing 1 - name: thing2 desc: I am thing 2 tasks: -…
Dave McNeill
  • 443
  • 4
  • 12
3
votes
2 answers

Compare attribute with number literal

I am trying to find all VMs with exactly 2 cores: $ az vm list-sizes -o json --query "[?numberOfCores == 2]" az vm list-sizes: error: argument --query: invalid query value: '[?numberOfCores == 2]' As I suspected an error with the az command, I…
user3151902
  • 3,154
  • 1
  • 19
  • 32
3
votes
5 answers

return text list of values one line per instance-id with awscli --query

I have instances in AWS that have the same ReservationId (they were launched at the same time and they have AmiLaunchIndex of 0 thru x ). My goal is to produce text output with one line per instance, such as this. I added column headers for…
LHWizard
  • 2,121
  • 19
  • 30
3
votes
2 answers

AWS CLI - How to query snapshots created after a specific date

I'm trying to query the snapshots created after a specific date and it is returning no results. The query I am trying is below: aws ec2 describe-snapshots --query 'Snapshots[?StartTime >= `2017-06-01`].{id:SnapshotId}' --owner-ids nnnnnnnnnnn If I…
Willem van Ketwich
  • 5,666
  • 7
  • 49
  • 57
3
votes
1 answer

Ansible setting vars from with_items

I am attempting to run a template task per ec2 instance, grabbing variables from other registered variables. The instance date is stored in ec2.tagged_instances, the IP information for the other two interfaces are stored in eni_dc and eni_spoke…
mcaulifn
  • 170
  • 2
  • 8