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
1 answer

How to filter element of list with a list in ansible with a json_query or other

I created an ansible playbook. And I want a task executed only if a json_query returns element. The json query have to returned an array searching if in an element from array of array exists in an element of another array. I already tried using…
DidierC
  • 33
  • 4
2
votes
1 answer

JSON parsing using String Condition with JMESPATH

I am facing an issue with parsing a json using Jmespath based on a string condition. I would want to get values of a key based on condition on string value of another key. Both of them are in same hierarchy of a given dictionary. However , the…
ram
  • 133
  • 6
2
votes
1 answer

How to insert a attribute with a dynamic value in many object or add an element dynamically in many array?

I want to add an attribute in many object(situated in an array) and this value will be get dynamically. I use the JSON below, and I already made a query to extract what I want. We will start with th result of this query. First my entire JSON: [ …
bosskay972
  • 890
  • 1
  • 6
  • 27
2
votes
2 answers

JMESPath query for nested array structures

I have the following data structure as a result of aws logs get-query-results: { "status": "Complete", "statistics": { "recordsMatched": 2.0, "recordsScanned": 13281.0, "bytesScanned": 7526096.0 }, …
fjf
  • 138
  • 3
  • 9
2
votes
1 answer

AWS CLI - Get all CloudFormation stacks that have a name that starts with string

What query should I use to get all CloudFormation stacks that start with a specific string? I have tried the following query, but it always returns an empty array: aws cloudformation describe-stacks --no-paginate --query…
Kappacake
  • 1,826
  • 19
  • 38
2
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
  • 5,289
  • 10
  • 49
  • 82
2
votes
1 answer

AWS CLI - result using jmespath query

I've a problem so you will safe my life :-) when I run the following command from aws-shell cloudformation describe-stacks --query…
2
votes
1 answer

Filter JSON object based on children keys

I am trying to find a procedural way of applying the following filter. Given the following object, how can I get all top-level keys that contain child c2? { "a1" : { "b" : { "c1": {}, "c2": {} } }, "a2" : { "b" : { …
Hubert Grzeskowiak
  • 15,137
  • 5
  • 57
  • 74
2
votes
1 answer

jmespath: Differentiate between a key not found and a key having a null value

I am using the jmespath module in python to search through a nested dictionary. The problem I am running into is that I want to raise an exception if the key is not found in the dictionary. However, some of the keys have None values, which is…
K Stroud
  • 53
  • 1
  • 4
2
votes
2 answers

Using JMESPath, how to filter Consul services which have at least one label defined?

I have a list of services defined in my Consul catalog, and I would like to remove the ones that have no label defined. This list of services looks like this: { "json": { "consul": [], "consul-exporter": [], …
Riduidel
  • 22,052
  • 14
  • 85
  • 185
2
votes
1 answer

Multiple searches with with json_query/jmespath filter in Ansible

I'm trying to parse out specifc subnet names in the following piece of json, while using contains_with or starts_with filters in json_query. It contains two vnets each of which has multiple subnets: { "azure_virtualnetworks": [ { "name":…
Setanta
  • 941
  • 1
  • 12
  • 24
2
votes
3 answers

Filter a JSON document in Ansible

I have a JSON reply from a GitHub repository with a list of possible downloads for a certain release (the assets array in the document). I want to get the browser download URL when the name of an asset ends with x64.AppImage. In Ansible, the filters…
Adri C.S.
  • 2,909
  • 5
  • 36
  • 63
2
votes
2 answers

AWS CLI - JMESPath query to find vpc-id by tag

I want to list the VPC id's which have a particular tag (Name=MyVPC). I am aware that I can use --filter and run: aws ec2 describe-vpcs --filters Name=tag:Name,Values=MyVPC --query 'Vpcs[].VpcId' This works completely fine. Is there a way I can…
Shravan
  • 141
  • 7
2
votes
1 answer

Concatenate result element of JMESpath multiselect filter with a variable

I have following variable structure in Ansible (YAML format): my_groups: - name: g1 users: - name: foo param: rock junk: whatever - name: bar param: paper junk: whatever - name: g2 users: …
Vojta Myslivec
  • 140
  • 1
  • 1
  • 8
2
votes
1 answer

Change JSON key using jmespath

Is there any reason to change or transform JSON key to something else using jmespath? For example if I have JSON like this: [ {"topic_id": 123, "name": "Topic 1"}, {"topic_id": 234, "name": "Topic 2"} ] how to change the "topic_id" to simply "id"?…
nazieb
  • 91
  • 1
  • 8