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
0 answers

How to conditionally select a property using JMESPath

e.g., from the data below I need to select names based on the preference: [ { "first_name": "Waseem", "last_name": "Khan", "preferred": "first" }, { "first_name": "Jawad", "last_name": "Hussain", "preferred": "last" …
WSK
  • 5,949
  • 8
  • 49
  • 74
2
votes
0 answers

How to join two json objects into key value pairs using JMESPATH

The below JSON has had me stumped for hours. The DataSource.Headers contains the headers for all over the values contained in the DataSource.Rows. I'm trying to get the Header in position [0] to correspond with the value [0] in each DataSource.Rows…
Rob See
  • 33
  • 4
2
votes
1 answer

JMESPath Path Where Key Might Not Exist

I have a weird JSON construct (I cannot provide the actual data for security reasons, but I can provide the structure, which is all that really matters). Given the following structure: [ { "a": { "b": { "c": "d" } } …
Eagle4
  • 23
  • 4
2
votes
1 answer

Create list of dict filtering different value with Ansible

I'm looking for a better solution to filter a list of dicts by a key A and return a list of value of key B. To be more concrete - every host has a dict: infrastructure: name: "x..." network: address: "1..." There are hosts, where…
TRW
  • 876
  • 7
  • 23
2
votes
1 answer

Remove square brackets from JMESPath expression

I have following JSON: { "694992": [ { "domain": "example.com", "domain_id": 49392164, "data": [ { "category": "Main", "category_id": 77133, …
Evgeniy
  • 2,337
  • 2
  • 28
  • 68
2
votes
1 answer

JMESPATH does not contains/starts_with

{ "data": { "edges": [ { "node": { "id": "ABC12345", "tags": [ { "name": "Dummy" }, { "name": "HelloT" } ] } …
Jason
  • 21
  • 1
  • 2
2
votes
2 answers

Conditional if/then/else for JMESPath?

Am trying to do a simple if/then/else using JMESPath For example: 'if the input is a string, return the string, else return the "value" property of the input'. An input of "abc" would return "abc". An input of {"value":"def"} would return "def" With…
mwag
  • 3,557
  • 31
  • 38
2
votes
1 answer

How to use variable in JMESPath expression?

The regular expression works perfect as below: jmespath.search(currentStats, 'Items[?Name == Annie]') But I want to make my filtered key as a variable. I have tried var name = "Annie" jmespath.search(JSONdata, 'Items[?Name == %s]' %name;) Which does…
Sam Min Wong
  • 151
  • 3
  • 18
2
votes
1 answer

xargs not splitting on whitespace from aws cli output

This commands returns all the AWS regions separated by whitespace: aws ec2 describe-regions --query 'Regions[*].RegionName' --output text eu-north-1 ap-south-1 eu-west-3 eu-west-2 eu-west-1 ap-northeast-2 ap-northeast-1 sa-east-1 …
red888
  • 27,709
  • 55
  • 204
  • 392
2
votes
2 answers

Using item in Ansible json_query

I'm trying to loop through a list of keys to grab associated names from some json: - name: show names debug: msg: "{{ data.json | json_query(query) }}" vars: query: "[? key==item].name" with_items: "{{ keys.split() }}" But it never…
EamonDawes
  • 75
  • 5
2
votes
1 answer
2
votes
1 answer

mongodb / jsonpath / jmespath expression to filter object with properties that contain special or accented characters

I need to filter the objects that contain special characters in this json. (I can either write a javascript or import and query the data in mongo. ) { "Detail": [{ "name": "somename1", "text": "Sometext1" }, …
Silver.Rainbow
  • 425
  • 4
  • 14
2
votes
1 answer

JMESPATH for counting number the of values beginning with specific string

Provided the JSON below, how would I construct a JAMESPATH script to return the number of times the value in the "Code" key begins with "BS" In this example my expected return would be: "2" Thanks in advance! { "Data": { "Matches": { …
Joey Iglesias
  • 461
  • 4
  • 9
2
votes
2 answers

how to use aws route53 list-resource-record-sets cli

I am trying to use aws route53 cli command to list out resource record sets in a zoneId with a query aws route53 list-resource-record-sets \ --hosted-zone-id $zoneId \ --query "ResourceRecordSets[?Name == 'abcd.example.com.']" But I am getting…
Saurav Dutta
  • 157
  • 3
  • 9
2
votes
5 answers

advanced JSON query language

I've explored couple of existing JSON query language such JMESPath, JsonPath and JSONiq. Unfortunately, none of them seem to be able to support my use case in a generic way. Basically, I'm receiving different type of responses from different web…
mathpaquette
  • 406
  • 4
  • 16