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

Extract nested arrays from dict using jmespath

I have this array of dicts containing arrays out of the Ansible output of an acme_certificate for DNS challenges ({{ le_challenges.results | json_query('[].challenge_data_dns') }}): [ { "_acme-challenge.foo.example.de": [ "" …
Skynet
  • 558
  • 3
  • 16
2
votes
2 answers

Filtering elements in nested list with json_query

I'd like to filter out entries from a nested list depending on a presence of a key. Given the following dictionary: hostvars: host1: backups: - src: somesource target: sometarget - src: anothersource host2: backups: …
Clayton Louden
  • 1,056
  • 2
  • 11
  • 28
2
votes
1 answer

JMESPath Query in Ansible

--- EDIT --- Partial-Solution: Messed around with the JMESPath syntax and was able to successfully get a match for the first test case (without the optional variable) using: jmesquery: "{{ datacenter }}{{ subcategory }}.{{ refine_hosts…
Andrea G.
  • 23
  • 5
2
votes
1 answer

Getting error template error while templating string: No filter named 'json_query'

With this playbook --- - name: ReadJsonfile hosts: localhost tasks: - name: Display the JSON file content shell: "cat config.json" register: result - name: save the Json data to a Variable as a Fact set_fact: …
Ashar
  • 2,942
  • 10
  • 58
  • 122
2
votes
2 answers

Unable to read json data in ansible play

I have the below json data file: [ { "?xml": { "attributes": { "encoding": "UTF-8", "version": "1.0" } } }, { "domain": [ { "name": "mydom" }, …
Ashar
  • 2,942
  • 10
  • 58
  • 122
2
votes
2 answers

Return objects in list that the first name starts with a certain value

I am trying to filter through this list of objects and only return the objects where the firstName starts with a specific value. [ {"firstName":"Paul","lastName":"Collins"}, {"firstName":"Jerry","lastName":"Johnson"}, …
cmcdev
  • 75
  • 9
2
votes
1 answer

JMESPath to filter on object instead of array

Sorry, I tried but simply cannot get my JMESPath filtering works to filter Github GraphQL for private repos. Here is the Github GraphQL result I want to filter: { "data": { "repositoryOwner": { "repositories": { "edges": [ …
xpt
  • 20,363
  • 37
  • 127
  • 216
2
votes
1 answer

Copy some k,v from existing JSON to constitute another JSON in Python

I have this JSON : { "duration": 1942, "frame_id": 0, "detect1": [ { "type": { "s_type1": [ { "confidence": 98.70016, "klass": -1, …
Ib D
  • 391
  • 1
  • 5
  • 17
2
votes
1 answer

what does @ symbol do in this [@][] ansible code?

I would like to know what @ symbol does in this line of code and [@][] do? This is being used in Ansible. Thank you. json_query("response.result.job | [@][]") The whole code: - name: task1 cmd: 'show jobs…
2
votes
2 answers

Filter JSON using Jmespath and return value if expression exist, if it doesn't return None/Null (python)

How can I get JMESPath to only return the value in a json if it exists, if it doesn't exist return none/null. I am using JMESPath in a python application, below is an example of a simple JSON data. { "name": "Sarah", "region": "south west", …
schosen
  • 61
  • 1
  • 5
2
votes
2 answers

Ansible reading nested json values and matching variable

I am using this in an Ansible playbook: - name: Gather info from Vcenter vmware_vm_info: hostname: "{{ result_item.vcenter }}" username: "{{ ansible_username }}" password: "{{ ansible_password }}" validate_certs: no register:…
Julia L
  • 57
  • 6
2
votes
1 answer

Ansible, how to access variables which were imported from a file?

I have a yml file (cert_expiring.yml) that I'm generating in my playbook and it consists of a dictionary of IDs and server names of servers whose SSL certs are expiring. Ex: cert_expiring.yml myDict: 705:node1.corp.com 670:node2.corp.com …
stminion001
  • 333
  • 2
  • 15
2
votes
1 answer

how to get json_query display property name in ansible playbook

I have this json block as an example: "msg": { "10.10.28.10": { "core": 23, "cpuCoreUsage": 0.0, "cputhreshold": 80, "status": "healthy", "status_code": 0, …
2
votes
1 answer

How to get nested data in JMESpath?

I have tried a couple of things, but my goal is simply to get access to last, for example, while using wildcards for 2021-02-12:5 and the 610.0 section. { symbol:symbol,test:putExpDateMap.*.[*].last} is closest I have gotten to success but no cigar,…
WTJJ
  • 103
  • 10
2
votes
1 answer

Filter nested array using jmes query

I have to get the name of companies in which 'John' worked in the 'sales' department. My JSON looks like this: [ { "name" : "John", "company" : [{ "name" : "company1", …
HyperioN
  • 3,433
  • 2
  • 22
  • 36