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

Access dictionaries values with dynamic keys

When I run the following task: - name: Get info about DVPG community.vmware.vmware_dvs_portgroup_info: hostname: "{{ vcenter_hostname }}" username: "{{ vcenter_username }}" password: "{{ vcenter_password }}" datacenter: "{{…
Bizargorri
  • 11
  • 3
1
vote
1 answer

Query a JSON where keys have spaces with JMESPath in Python

I have a json which looks likes this: [ {"First Name": "xyz", "Last Name": "abc", "Name": "name1"}, {"First Name": "abc", "Last Name": "xyz", "Name": "name2"}, {"First Name": "abcd", "Last Name": "wxyz", "Name": "name3"} ] I am able to easily…
1
vote
1 answer

Parse and filter json output in Ansible via json_query

I have the below output that I'm trying to parse and filter: - name: lvs debug: msg: "{{ ansible_lvm.lvs }}" ok: [localhost] => { "msg": { "av_root_snapshot": { "size_g": "4.00", "vg": "vg_root" …
pilipeet
  • 47
  • 6
1
vote
2 answers

AttributeError: module 'jmespath' has no attribute 'search'

I encountered that error: import jmespath AttributeError: Module jmespath has no attribute search I used the version 1.0.1 of this module. I wanted to run the following code: import jmespath person = { "person": [ {'id': 1, 'name':…
alirhm
  • 13
  • 3
1
vote
1 answer

How to add value to array with JMESPath?

With the following JSON: { "resource_access":{ "info-bi-test":{ "roles":[ "DB7" ] } } } How to add another value to an array resource_access."info-bi-test".roles with JMESPath? I read the…
1
vote
2 answers

JMES Path "contains" missing argument in parameter list

I'm attempting the following Azure CLI command and query from PowerShell: az account list-locations --query [?contains(name,"us")].[displayName,name] Unfortunately the --query parameter gives me this error: Missing argument in parameter…
Brent Arias
  • 29,277
  • 40
  • 133
  • 234
1
vote
1 answer

JMESPath array flatten + create key:value pair

I have a JSON object which I'd like to turn into a dictionary. The object looks like this: { "data": { "votes": [ { "id": "0x0d185b44dc6a9e4077d44a29fccc22d1f6238192107d08afa890a1bdddc01e10", "voter":…
Sam Polgar
  • 25
  • 4
1
vote
2 answers

JMESPath query using the contains function is giving a syntax error

I am searching through Azure container and want to filter out blobs ending with certain suffixes. When I use the --query parameter with a JMESPath contains function, it is giving me an error. When I run the command az storage blob list \ …
1
vote
1 answer

Custom query with more than one field on az ad sp list

Lets say I want to list id and appId from az ad sp list, how would one do that? I get it working for only the id like this: az ad sp list --query '[].id' How can I extend this to id and appId? I already tried az ad sp list --query…
stefan.at.kotlin
  • 15,347
  • 38
  • 147
  • 270
1
vote
1 answer

How to filter for multiple identifier values in AWS CLI

When filtering multiple identifier values in the AWS CLI, the results are the same with or without a period. Is the period optional? The official references does not mention that it can be omitted. AWS Command Line Interface: Filtering for multiple…
ysdkk9409
  • 15
  • 4
1
vote
1 answer

Ansible json_query'd json to yaml inventory with variables

I have an ansible json_query'd result that I'm trying to use as the inventory for another playbook and my noob skills at manipulating data are lacking. The json_query is: community.general.json_query('device_info.value[].{ hostname: DeviceName,…
ThatGuyJ
  • 11
  • 1
1
vote
0 answers

JMESPath to create a dictionary (map) out of Tags key and value pairs from AWS CLI output

I am trying to extract a few properties of AWS EC2 instance using JMESPath. I just started learning JMESPath using this useful guide. But because my knowledge is limited, I was only able to get the output like below. % aws ec2 describe-instances…
user1330974
  • 2,500
  • 5
  • 32
  • 60
1
vote
1 answer

How to check if task output list contains a string using filter or JMESPath?

I am writing a simple Ansible playbook (Ansible version - 2.9) to start a service and then want to extract certain fields – "changed" and "failed" – from the output for debugging purpose These are my tasks: - name: Start service if stopped …
adbdkb
  • 1,897
  • 6
  • 37
  • 66
1
vote
1 answer

Can you print the values of a JSON array in an AWS, using a JMESPath query?

I am trying to list all the SQS queues in our account using aws sqs list-queues into a bash one-item-per-line output. Problem is it comes through as a JSON object { "QueueUrls": [ "url", "url", "etc..." ] } I can use JMESpath to get…
WesAtWork
  • 65
  • 7
1
vote
1 answer

How to deal with potential null value in a sort_by?

I have an array of objects like so: { "openingDates": [ { "location": "Main St.", "openingDate": "2023-01-09T00:00:00Z" }, { "location": "Northwood Park", "openingDate":…
mortimerfreeze
  • 199
  • 1
  • 1
  • 9