Skip to content

Commit ab4d585

Browse files
authored
Merge pull request #15697 from Kurt-von-Laven/patch-2
Add example for object filter on object.
2 parents a980e80 + 664e7da commit ab4d585

File tree

1 file changed

+37
-1
lines changed

1 file changed

+37
-1
lines changed

content/actions/learn-github-actions/expressions.md

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -366,4 +366,40 @@ For example, consider an array of objects named `fruits`.
366366
]
367367
```
368368

369-
The filter `fruits.*.name` returns the array `[ "apple", "orange", "pear" ]`
369+
The filter `fruits.*.name` returns the array `[ "apple", "orange", "pear" ]`.
370+
371+
You may also use the `*` syntax on an object. For example, suppose you have an object named `vegetables`.
372+
373+
```json
374+
375+
{
376+
"scallions":
377+
{
378+
"colors": ["green", "white", "red"],
379+
"ediblePortions": ["roots", "stalks"],
380+
},
381+
"beets":
382+
{
383+
"colors": ["purple", "red", "gold", "white", "pink"],
384+
"ediblePortions": ["roots", "stems", "leaves"],
385+
},
386+
"artichokes":
387+
{
388+
"colors": ["green", "purple", "red", "black"],
389+
"ediblePortions": ["hearts", "stems", "leaves"],
390+
},
391+
}
392+
```
393+
394+
The filter `vegetables.*.ediblePortions` could evaluate to:
395+
396+
```json
397+
398+
[
399+
["roots", "stalks"],
400+
["hearts", "stems", "leaves"],
401+
["roots", "stems", "leaves"],
402+
]
403+
```
404+
405+
Since objects don't preserve order, the order of the output can not be guaranteed.

0 commit comments

Comments
 (0)