Skip to content

Commit 4ce6cff

Browse files
Add example for object filter on object.
There was already an example for using an object filter on an array. Clarify that object filters can be used on objects as well and that the result is an array, not an object.
1 parent 932c87f commit 4ce6cff

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)