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

ansible convert escaped json string to json

I have an Ansible output that looks like this but have struggled to parse this to JSON without the escaped strings. { "msg": [ "{", "\t\"inprog\" : [", "\t\t{", "\t\t\t\"desc\" : \"conn174272\",", …
ezeagwulae
  • 289
  • 7
  • 22
2
votes
2 answers

JmesPath join or concatenate nested array elements

I realize there are several other JmesPath join questions here, but I'm having trouble with a separate problem that I haven't found any examples for, where I need to concatenate (ie, join) a set of JSON values that have dynamically-named keys into a…
JamesWilson
  • 3,833
  • 2
  • 30
  • 40
2
votes
1 answer

Filter out ASGs that contain string in AutoScalingGroupName using boto3

I am attempting to filter out auto scaling groups that contain the string 'base' in AutoScalingGroupName. I'm trying to use the JMESpath query language but cannot find any examples on filtering by the value, only for key. import boto3 session =…
Gorgon_Union
  • 563
  • 2
  • 8
  • 24
2
votes
1 answer

Ansible task - how can I loop over all predefined vars to create linux groups in this format?

I have a predefined ansible variables, and I want to create linux groups from these variables. The below task create only the groups in the first array g1,g2,g3 How can I loop over all lines to create other groups? The predefined ansible…
2
votes
1 answer

How to transform a nested dictionary into a list using json_query?

I do have a nested dictionary that looks like: mydict: system: # <-- group disk: # <-- command name cmd: df -a memory: cmd: free hw: pci: cmd: lspci foo: bar I would like to transform it into a list of…
sorin
  • 161,544
  • 178
  • 535
  • 806
2
votes
2 answers

What's the best way to pick another JSON key if the first not exists using JMESPath?

There's JSON with some product data, as an example: { "sku": 123, "product": { "name": "Some name", "images": { "normalImage": "http://somelink.com/1.jpg", "bigImage": "http://somelink.com/1b.jpg" } } } I want to pick…
sortas
  • 1,527
  • 3
  • 20
  • 29
2
votes
1 answer

List volumes missing specific tags

I am trying to list Volumes from the AWS CLI that is missing a specific tag key. While I can list volumes missing a specific key with below command. aws ec2 describe-volumes --query 'Volumes[?!not_null(Tags[?Key == `MakeSnapshot`].Value)] |…
IgniteLX
  • 75
  • 3
2
votes
1 answer

Extract App Service Plan Azure Resource list with AZ CLI

I'm trying to extract all APP service plan in a Azure subscription with az cli. Command is az resource list, output below [ { "id":…
Cyber.Drunk
  • 165
  • 2
  • 12
2
votes
1 answer

Filtering JMESPath with a string

I can't find the solution despite a lot of research. I'm stuck with the contains function. I have this Json file: { "from": "Api", "success": true, "message": "", "errors": [], "data": { "operations": [ { …
user2030243
  • 49
  • 1
  • 6
2
votes
1 answer

filtering geoJSON data using JMESPath not working

I am trying to filter some data from the geoJSON data structure shown as below: "features": [ { "type": "Feature", "properties": { "@id": "node/7071544593", "addr:city": "Joensuu", "addr:housenumber": "12", …
Mohsin
  • 73
  • 2
  • 9
2
votes
1 answer

JMESPath date filtering

I am trying to convert an Ansible script to a Python AWS lambda function. In my Python script I am using the jmespath library to filter by date, which is given as a string in ISO 8601 format. My filter works in my Ansible script and also using the…
modevops
  • 23
  • 1
  • 3
2
votes
1 answer

Why aren't my [] flattening my jmespath array

I'm trying to get the OwnerId, StackId, and InstanceId output on the same line. I run the below command with the --output-text option, and it puts the "some_stack" data on a different line. aws ec2 describe-instances --profile 1234 --filters…
jars99
  • 25
  • 4
2
votes
2 answers

ModuleNotFoundError: No module named 'jmespath'

I am trying to download a flower dataset from Open Images Dataset, using OIDv4(https://github.com/EscVM/OIDv4_ToolKit) The program can run, but the end result is a huge CSV file comprising of the entire Open Images Dataset and zero images I am…
Extech
  • 51
  • 1
  • 2
  • 4
2
votes
3 answers

Using JMESPath, filter array elements based on length of an array-valued property

Given an input like this: [ { "a": "foo", "b": [ 1, 2, 3 ] }, { "a": "bar", "b": [ ] }, { "a": "baz", "b": [ 2 ] } ] I want to filter out the elements that have a zero-length array for their b property to…
James World
  • 29,019
  • 9
  • 86
  • 120
2
votes
1 answer

How to tweak JSON in place using jmespath

Using the example on the jmesPath home page, given this JSON: { "locations": [ {"name": "Seattle", "state": "WA"}, {"name": "New York", "state": "NY"}, {"name": "Bellevue", "state": "WA"}, {"name": "Olympia", "state": "WA"} …
John Arrowwood
  • 2,370
  • 2
  • 21
  • 32