[{
"backup": "b3",
"time_ended": "2020-09-10T14:55:39.840000+00:00"
}, {
"backup": "b2",
"time_ended": "2020-08-25T15:40:48.740000+00:00"
}, {
"backup": "b1",
"time_ended": "2020-07-10T15:40:48.740000+00:00"
}]
@alonsocamaro - THe homepage for JMESPath can be used as an online evaluator if desired. Its a real-time test and you can manipulate the search and json structure that will be searched.
I have not ran into an issue where it has "failed" for me thus far unless there is an error in my syntax which is most likely the cause of your not updating. That is one area where it lacks is it doesn't let you know when the syntax has an error so its likely assumed to be a web-based error. If you have a specific scenario/filter feel free to type it here and if I am paying attention will attempt to help.
I asked this on stackoverflow as well, but thought I'd ask it here to try and get some traction.
AWS's list-secrets
has an odd way of listing version strings as keys:
{
"SecretList": [
{
"Name": "sandbox_config",
"Description": "sandbox config file",
"SecretVersionsToStages": {
"2895f1a4-bcae-46b2-9a45-4f06f490d8ed": [
"AWSCURRENT"
],
"336a5030-cd81-4626-a100-1aa68b70b5b1": [
"AWSPREVIOUS"
]
}
}
]
}
I'm trying to figure out a query that will let me pull out the versionkey where AWSCURRENT
is in the value array.
This seems like it's close:
SecretList[].{Version:SecretVersionsToStages.*[?@==`AWSCURRENT`]|[]|[0] }
But I'm clearly missing something, since that just spits back AWSCURRENT
to me.
If you could... would you want to be able to do something like this:
expect(
search([6.1, 4.2, 6.3], "_groupBy(@, as_lambda('Math.floor'))")
).toStrictEqual({
'4': [4.2],
'6': [6.1, 6.3],
});
or perhaps
expect(
search([1, 2], "_flatMap(@, as_lambda('x => [x, x]'))")
).toStrictEqual([1, 1, 2, 2]);
Thoughts?
_flatMap
, _groupBy
and 184 other (fully typed) functions have been built into JMESPath expressions in our https://www.npmjs.com/package/@metrichor/jmespath-plus library. Level-up your JMESPath expressions with the power of lodash functions. Check out https://github.com/nanoporetech/jmespath-plus/releases/tag/v0.3.0 for a complete list of supported lodash functions
{
"subject": [
"Fwd: Please complete your assigned training"
],
"labelIds": [
"UNREAD",
"CATEGORY_PERSONAL",
"Label_6568222846829069483",
"INBOX"
]
}
{subject:payload.headers[?name=='Subject'].value,labelIds:labelIds}
{subject: payload.headers[?name=='Subject'].value, labelIds:map(&(!contains(['UNREAD', 'CATEGORY_PERSONAL', 'INBOX'], @) && [@]) || [] ,labelIds)[]}
OR {subject: payload.headers[?name=='Subject'].value, labelIds:labelIds[*][(!contains(['UNREAD', 'CATEGORY_PERSONAL', 'INBOX'], @) && @) ||[]][]}
Hi everyone, I have a question. Is it possible to use the result of a query to search again? For example, say we have the slightly modified example from jmespath.org
{
"locations": [
{"name": "Seattle", "state": "WA"},
{"name": "New York", "state": "NY"},
{"name": "Bellevue", "state": "WA"},
{"Seattle": "Olympia", "state": "WA"}
]
}
could this query
{value: @, key: keys(@)[?ends_with(@, 'Seattle')]} | @.value.[@.key]
return "Olympia"??
locations[?ends_with(state, 'A')].name
v1
&& involvedObject.kind == Service
&& involvedObject.name==my-name
].{ firstTimestamp: firstTimestamp, lastTimestamp: lastTimestamp, count: count, reason: reason, message: message }
search([-x:], [0, 1, 2, 3]) -> [2, 3]
where x is a number - the last x entries
for the last 5 you'd do something like
resources[?involvedObject.apiVersion == v1 && involvedObject.kind == Service && involvedObject.name==my-name].{ firstTimestamp: firstTimestamp, lastTimestamp: lastTimestamp, count: count, reason: reason, message: message }[-5:]
...at least that's what I think you'd have to do
{
"tags": {
"private_password_reset": {
"tag_name": "PasswordResetSettings"
},
"users": {
"tag_name": "users"
}
}
}
result should be: PasswordResetSettings, users
join(', ', tags.*.tag_name)