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)