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 . JMESPath allows you to extract elements from a JSON document. It also allows you to directly transform the queried elements. So to speak, JMESPath is for JSON what is for . For questions on JSON itself please use the tag.

Useful Links:

295 questions
0
votes
1 answer

Is there a way to access values from top array while also getting info from nested array using jmespath?

I got an issue when trying to convert my json with nested objects into several objects. Looking at my json below, you can see an example of what i got { "name": "Isa Hemd ", "colors": [ { "color": "Deep Forest", "sizes": [ …
0
votes
1 answer

filter out text from a complex json object created by an ansible register of gentent module using a json_qry

Specifically I want a "string" of account IDs that are missing from a list I give the task on a server in my inventory. I run the getent module in the task and I register the result which seems to be a complext JSON object with the data I want as a…
ray.licon
  • 1
  • 1
0
votes
0 answers

ansible/json_query join to list on 2 keys

I've got two lists of dictionaries, with each key two common keys. I'd like to have the union of this list, what is the prettier way to do so? Input: L1= [ { "k1": "1", "k2': "2", "v": "b" }, { "k1": "3", "k2': "4", "v": "a" } ] L2 = [ {…
Raoul Debaze
  • 308
  • 5
  • 17
0
votes
1 answer

JMESPath multiple filters

I want to get instances with a tag that has a value. aws ec2 describe-instances --query \ 'Reservations[].Instances[? Tags[?Key==`datadog` && Value==`true`] ].Tags' However I'm not getting my results this way. If I remove the && Value=='true' I'm…
Moshe
  • 2,673
  • 3
  • 19
  • 41
0
votes
2 answers

Merge sub-hashes within an array in JMESPATH

I have a hash of hashes 5 layers deep. At level 3 I have Docker images. I used JMESPATH query projects.*.docker_images to retrieve these images. Now I have a result like this: [ { "image1": { "registry_url": "blah" } }, { …
EdwardTeach
  • 297
  • 2
  • 13
0
votes
2 answers

transform values of yaml hash into keys of json hash in Ansible

I'm trying to get Ansible to convert an array of hashes, into to a list of key value pairs with the keys being one of the values from the first hash and the values being a different value from the first hash. An example will help. I want to…
0
votes
2 answers

JMESPath extract raw values from list

I'm trying to do some scripting with the Azure CLI. Say that my query is returning the following: [ "a", "b", "c" ] I want to use these values in a bash loop. It would be much nicer to get them in the following form: a b c Is there a way to…
s g
  • 4,057
  • 6
  • 39
  • 67
0
votes
1 answer

JMESPath JSON filter with mutiple sub childs

I have json block which looks like below. I'm using the Jmespath PHP library to get the categories from the below JSON input. I'm using the following query(_element[].[name, display-name, self.uri]) to returns the parent categories in the simple…
Naveen Valecha
  • 196
  • 1
  • 10
0
votes
1 answer

Need james path output

Here is my output from azure cli with -o json output. [ { "cloudName": "AzureCloud", "id": "xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx", "isDefault": true, "name": "CSC Number One", "state": "Enabled", "tenantId":…
user8588795
  • 184
  • 10
0
votes
1 answer

How to Json query in Ansible

I am using ec2_lc_facts ansible module and registering the output to a variable called lc_facts. I am able to grab the block_device_mappings value using json query "{{ lc_facts.launch_configurations|json_query('[*].block_device_mappings') }}" but…
sherri
  • 251
  • 1
  • 4
  • 12
0
votes
2 answers

jmespath search nested array issue

I need to search all dict in a nested array as below by its key with jmespath my_list = [[{'age': 1, 'name': 'kobe'}, {'age': 2, 'name': 'james'}], [{'age': 3, 'name': 'kobe'}]] I got an empty list with jmespath search:…
Lucent
  • 23
  • 3
0
votes
2 answers

How to merge JSON using JMESPATH?

So the thing is that I have a JSON looking a little bit something like this: { "country": "USA", "states": [ { "stateName": "California", "timeZone": "UTC-8", "cities": [ { "cityName": "Los…
Mati Picc
  • 3
  • 1
0
votes
1 answer

wp rest api filter nested array jmespath

I'm trying to filter a wpapi request, using Jmespath o standard built in filter string. I would like to retrive all "id" in the list with one or more values in the "filters" array. "Filters" is nested under "_item_filter-options". For ex I would…
Tore78
  • 1
  • 2
0
votes
1 answer

Filter on nested array with jmespath (using az cli)

I would like to know if a value in a TXT record is already available in the DNS: az network dns record-set txt show -g myresourcegroup -z 'mydomain' -n 'mytxtvalues' This is the part of the json result where it's all about: "txtRecords": [ { …
Pascal Naber
  • 1,064
  • 8
  • 13
0
votes
1 answer

JMESPath descend in tree for filter

What I'm trying to achieve I want to extract the volume ID for the root block device using describe-instances. What I tried so far aws ec2 describe-instances --filters "Name=tag:Backup,Values=True" --query 'Reservations[].Instances[].{Name:…
Yaron
  • 1,101
  • 1
  • 14
  • 29