Skip to content

Commit

Permalink
Merge pull request github#15697 from Kurt-von-Laven/patch-2
Browse files Browse the repository at this point in the history
Add example for object filter on object.
  • Loading branch information
ramyaparimi authored Mar 25, 2022
2 parents a980e80 + 664e7da commit ab4d585
Showing 1 changed file with 37 additions and 1 deletion.
38 changes: 37 additions & 1 deletion content/actions/learn-github-actions/expressions.md
Original file line number Diff line number Diff line change
Expand Up @@ -366,4 +366,40 @@ For example, consider an array of objects named `fruits`.
]
```

The filter `fruits.*.name` returns the array `[ "apple", "orange", "pear" ]`
The filter `fruits.*.name` returns the array `[ "apple", "orange", "pear" ]`.

You may also use the `*` syntax on an object. For example, suppose you have an object named `vegetables`.

```json
{
"scallions":
{
"colors": ["green", "white", "red"],
"ediblePortions": ["roots", "stalks"],
},
"beets":
{
"colors": ["purple", "red", "gold", "white", "pink"],
"ediblePortions": ["roots", "stems", "leaves"],
},
"artichokes":
{
"colors": ["green", "purple", "red", "black"],
"ediblePortions": ["hearts", "stems", "leaves"],
},
}
```

The filter `vegetables.*.ediblePortions` could evaluate to:

```json
[
["roots", "stalks"],
["hearts", "stems", "leaves"],
["roots", "stems", "leaves"],
]
```

Since objects don't preserve order, the order of the output can not be guaranteed.

0 comments on commit ab4d585

Please sign in to comment.