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 is OData and JMESPath related?

I have come across JMESPath and would like to use JMESPath instead of OData (is it actually replaceable?) on asp.net webapi. Can someone shed some light on me please. Thanks in advance Pavan
Navap
  • 1,050
  • 9
  • 18
2
votes
1 answer

Search for an object in json by filtering on a value within that json using jmespath

I have a json file that essentially looks like this: { "input": { "user": "john", "group": "johns_group" }, "group_data": [ { "name": "johns_group", "members": ["john", "michael"] …
Anderson-A
  • 74
  • 1
  • 6
2
votes
2 answers

Retain null in nested JMESPath query with Ansible

I make an API call in ansible and analyse the response. A repro: --- - hosts: localhost gather_facts: false vars: response: { "results": [ { "item": "server1", "json": { "data": null, …
lonix
  • 14,255
  • 23
  • 85
  • 176
2
votes
1 answer

Get latest element with certain prefix in JMESPath

I have a JSON input like that: { "details": [ { "file": [ "xxx-abc" ], "filePushedAt": "2021-10-25T09:31:39+02:00" }, { "file": [ "xxx-dfg" ], "filePushedAt":…
Murakami
  • 3,474
  • 7
  • 35
  • 89
2
votes
2 answers

How to select an element in an array based on two conditions in JMESPath?

I'm trying to select the SerialNumber of a specific AWS MFADevice for different profiles. This command returns the list of MFADevices for a certain profile: aws iam list-mfa-devices --profile xxx and this is a sample JSON output: { …
David
  • 125
  • 8
2
votes
3 answers

Getting the values of keys of Ansible JSON output

I have the following JSON data { "docker_compose_init_result": { "changed": true, "failed": false, "services": { "grafana": { "docker-compose_grafana_1": { "cmd": [], …
2
votes
1 answer

How do I get Ansible's json_query to return a value from this JSON document

After several hours of beating my head against this (not to mention leaving it for a day) I'm pretty much stumped on trying to figure out why I can't JMESPath to return a value in Ansible. I have a task which runs a shell command and returns the…
avggeek
  • 375
  • 1
  • 2
  • 8
2
votes
1 answer

Does JMESPath support something like a spread operator?

Is it possible to convert this JSON: { "message": "Hello!", "contextMap": { "foo": 1, "bar": 2, ...otherInContextMap }, ...someOther } (where keys of contextMap are not known) into the following JSON: { "message": "Hello!", "foo": 1, "bar": 2,…
TN.
  • 18,874
  • 30
  • 99
  • 157
2
votes
1 answer

How do i select multiple if display-name is equal to in json file

Json Outpt I have { "data": [ { "agent-config": { "are-all-plugins-disabled": false, "is-management-disabled": false, "is-monitoring-disabled": false, "plugins-config": null }, …
Harry
  • 91
  • 7
2
votes
1 answer

Extracting keys from JMESPath expression in objects

I would like to extract the keys from those JSON objects in a JMESPath expression: {"wrapperType": "track", "kind": "song", "artistId": 657515} And this, independently of the values. My main goal is to get something like this: ["wrapperType",…
medisamm
  • 197
  • 1
  • 7
2
votes
2 answers

Ansible AWX issue - JMESPATH

I am facing an issue with AWX Tower instance. I have a project and job template on it and the job template is connecting to Ansible control node running on (Red Hat Enterprise Linux Server release 7.9 (Maipo)), where couple of playbooks are…
2
votes
1 answer

Implement a condition on a query JMESPATH

I have this query which bring me the expiring dates of the keyvault's secret, I have to bring the dates that are less than 30 days az keyvault secret show \ --vault name "$keyvault" \ --name "$secret" \ --query "attributes.expires" - o tsv How…
2
votes
1 answer

Parsing JSON output from Juniper switch using Ansible

I have this JSON output from Juniper switch where I need to get the remote system name associated with lldp_local_parent_interface_name having the value ae0. So, I only know the value ae0 and I need to get the remote system name A_B_C_D in order to…
DarkOne00X
  • 23
  • 3
2
votes
1 answer

Check for objects in JSON other than the one mentioned in a condition

I need to check if there are exit codes other than 0 in the JSON file below. { "domains": { "app1": { "status": "Running" }, "app2": { "status": "Terminated", "exit code": 2 }, …
Shaf av
  • 23
  • 4
2
votes
1 answer

json_query filter error - template error while templating string: expected token ','

I am trying to use the json_query filter to parse the desired JSON data. Ansible playbook task: - name: Print items in option ansible.builtin.debug: msg: "{{ clust_opts |…
bfowler
  • 49
  • 1
  • 9