Filter nested list of dictionaries #1781
Answered
by
Gervwyk
kemeris2000
asked this question in
Questions and Help
-
I can't figure out how to select list items which "options" array contains dictionary with name="Option1" and value="100".
expected result is: [ { "id": 1, "name": "Item1", "options": [ { "id": 104, "name": "Option1", "value": "100" }, { "id": 105, "name": "Option2", "value": "200" } ] } ] |
Beta Was this translation helpful? Give feedback.
Answered by
Gervwyk
Feb 1, 2024
Replies: 2 comments 2 replies
-
I have not tested it, but try this: _mql.aggregate:
on:
_state: my_data
pipeline:
- $match:
$expr:
$gt:
- $size:
$filter:
input:
$options
cond:
$and:
- $eq:
- $$this.name
- Option1
- $eq:
- $$this.value
- '100'
- 0 |
Beta Was this translation helpful? Give feedback.
2 replies
Answer selected by
kemeris2000
-
Correct link to jq JavaScript |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I have not tested it, but try this: