Skip to content

Commit

Permalink
Expand _.get documentation (#113)
Browse files Browse the repository at this point in the history
Expand _.get documentation with multi-path example and a link to the
underscorejs documentation
  • Loading branch information
hankjacobs authored Mar 31, 2024
1 parent 0de2415 commit 63e56f0
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions docs/expressions.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,10 @@ Given an example entry of:
{
"name": "Website",
"details": {
"description": "Marketing website"
"description": "Marketing website",
"owner": {
"team": "Engineering"
}
},
"runbooks": ["https://github.com/incident-io/runbooks/blob/main/website.md"]
}
Expand All @@ -86,16 +89,15 @@ The following expressions would evaluate to:
- `$.runbooks``["https://github.com/incident-io/runbooks/blob/main/website.md"]`
- `$.runbooks[0]``https://github.com/incident-io/runbooks/blob/main/website.md`


You can also use `get` to evaluate nested fields that may be null.
You can also [use `get`](https://underscorejs.org/#get) to evaluate nested fields that may be null.
For the example entry above, the following expressions would evaluate to:

- `_.get($.metadata, "name")``null`
- `_.get($.metadata, "name", "default name")``default name`
- `_.get($.details, "alias")``null`
- `_.get($.details, "alias", "default alias")``default alias`
- `_.get($.details, "description")``Marketing website`

- `_.get($.details, ["description", "owner", "team"])``Engineering`

## Migrating from CEL

Expand Down

0 comments on commit 63e56f0

Please sign in to comment.