Skip to content

Commit 4f3ef02

Browse files
authored
Consistently used JEP-12 JSON literals in examples. (#147)
* Consistently used JEP-12 JSON literals in examples. * Removed <blockquote> sidebar.
1 parent 5ca6f6a commit 4f3ef02

File tree

3 files changed

+33
-27
lines changed

3 files changed

+33
-27
lines changed

jep-003-functions.md

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ This document proposes modifying the
1414
[JMESPath grammar](https://jmespath.org/specification.html#grammar)
1515
to support function expressions.
1616

17+
**Note**: this document uses [JEP-12 JSON Literals](https://github.com/jmespath-community/jmespath.spec/blob/main/jep-012-raw-string-literals.md#abnf) such as strings like `` `"foo"` `` and numbers like `` `-1` ``.
18+
1719
## Motivation
1820

1921
Functions allow users to easily transform and filter data in JMESPath
@@ -259,9 +261,9 @@ As a final example, here is the steps for evaluating `abs(to_number(bar))`:
259261
260262
|Expression|Result
261263
|---|---
262-
| `abs(1)` |1
263-
| `abs(-1)`|1
264-
| ``abs(`abc`)``| |`<error: invalid-type>`
264+
| `` abs(`1`) `` | `1`
265+
| `` abs(`-1`) ``| `1`
266+
| `` abs(`"abc"`) ``| |`<error: invalid-type>`
265267
266268
### avg
267269
@@ -297,7 +299,7 @@ Returns the next highest integer value by rounding up if necessary.
297299
| ``ceil(`1.001`)`` | 2
298300
| ``ceil(`1.9`)`` | 2
299301
| ``ceil(`1`)`` | 1
300-
| ``ceil(`abc`)`` | `null`
302+
| ``ceil(`"abc"`)`` | `null`
301303
302304
### contains
303305
@@ -318,14 +320,14 @@ the string contains the provided `$search` argument.
318320
319321
|Given|Expression|Result
320322
|---|---|---
321-
| n/a | ``contains(`foobar`, `foo`)`` | `true`
322-
| n/a | ``contains(`foobar`, `not`)`` | `false`
323-
| n/a | ``contains(`foobar`, `bar`)`` | `true`
324-
| n/a | ``contains(`false`, `bar`)`` | `<error: invalid-type>`
325-
| n/a | ``contains(`foobar`, 123)`` | `false`
326-
| `["a", "b"]` | ``contains(@, `a`)`` | `true`
327-
| `["a"]` | ``contains(@, `a`)`` | `true`
328-
| `["a"]` | ``contains(@, `b`)`` | `false`
323+
| n/a | ``contains(`"foobar"`, `"foo"`)`` | `true`
324+
| n/a | ``contains(`"foobar"`, `"not"`)`` | `false`
325+
| n/a | ``contains(`"foobar"`, `"bar"`)`` | `true`
326+
| n/a | ``contains(`false`, `"bar"`)`` | `<error: invalid-type>`
327+
| n/a | ``contains(`"foobar"`, `123`)`` | `false`
328+
| `["a", "b"]` | ``contains(@, `"a"`)`` | `true`
329+
| `["a"]` | ``contains(@, `"a"`)`` | `true`
330+
| `["a"]` | ``contains(@, `"b"`)`` | `false`
329331
330332
### floor
331333
@@ -356,10 +358,10 @@ together using the `$glue` argument as a separator between each.
356358
357359
| Given | Expression | Result
358360
|---|---|---
359-
| `["a", "b"]` | ``join(`, `, @)`` | "a, b"
360-
| `["a", "b"]` | ```join(``, @) ``` | "ab"
361-
| `["a", false, "b"]` | ``join(`, `, @)`` | `<error: invalid-type>`
362-
| `[false]` | ``join(`, `, @)`` | `<error: invalid-type>`
361+
| `["a", "b"]` | ``join(`", "`, @)`` | "a, b"
362+
| `["a", "b"]` | ```join(`""`, @) ``` | "ab"
363+
| `["a", false, "b"]` | ``join(`", "`, @)`` | `<error: invalid-type>`
364+
| `[false]` | ``join(`", "`, @)`` | `<error: invalid-type>`
363365
364366
### keys
365367
@@ -399,7 +401,7 @@ Returns the length of the given argument using the following types rules:
399401
400402
| Given | Expression | Result
401403
|---|---|---
402-
| n/a | ``length(`abc`)`` | 3
404+
| n/a | ``length(`"abc"`)`` | 3
403405
| "current" | `length(@)` | 7
404406
| "current" | `length(not_there)` | `<error: invalid-type>`
405407
| `["a", "b", "c"]` | `length(@)` | 3

jep-006-improved-identifiers.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ identifier grammar rules will be fixed, along with an improved grammar for
1616
specifying unicode identifiers in a way that is consistent with JSON
1717
strings.
1818

19+
**Note**: this document uses [JEP-12 JSON Literals](https://github.com/jmespath-community/jmespath.spec/blob/main/jep-012-raw-string-literals.md#abnf) such as strings like `` `"foo"` `` and numbers like `` `-1` ``.
20+
1921
## Motivation
2022

2123
There are two ways to currently specify an identifier, the unquoted rule:
@@ -172,8 +174,8 @@ this is just a suggested syntax, not a formal proposal), given the data:
172174
You can now have the following JMESPath expressions:
173175

174176
```
175-
foo[?"✓" = ``]
176-
foo[?"\u2713" = `\u2713`]
177+
foo[?"✓" = `"✓"`]
178+
foo[?"\u2713" = `"\u2713"`]
177179
```
178180

179181
As a general property, any supported JSON string is now a supported quoted

jep-011-let-function.md

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ JMESPath to introduce scoping, but provides useful functionality such as being
1717
able to refer to elements defined outside of the current scope used to evaluate
1818
an expression.
1919

20+
**Note**: this document uses [JEP-12 JSON Literals](https://github.com/jmespath-community/jmespath.spec/blob/main/jep-012-raw-string-literals.md#abnf) such as strings like `` `"foo"` `` and numbers like `` `-1` ``.
21+
2022
## Motivation
2123

2224
As a JMESPath expression is being evaluated, the current element, which can be
@@ -34,7 +36,7 @@ to a parent element.
3436

3537
For example, suppose we had this data:
3638

37-
```
39+
```json
3840
{"first_choice": "WA",
3941
"states": [
4042
{"name": "WA", "cities": ["Seattle", "Bellevue", "Olympia"]},
@@ -50,7 +52,7 @@ unique in the `states` list. This is currently not possible with JMESPath.
5052
In this example we can hard code the state `WA`:
5153

5254
```
53-
states[?name==`WA`].cities[]
55+
states[?name==`"WA"`].cities[]
5456
```
5557

5658
but it is not possible to base this on a value of `first_choice`, which
@@ -136,7 +138,7 @@ examine the case where the identifier can be resolved from the
136138
current evaluation context:
137139

138140
```
139-
search(let({a: `x`}, &b), {"b": "y"}) -> "y"
141+
search(let({a: `"x"`}, &b), {"b": "y"}) -> "y"
140142
```
141143

142144
In this scenario, we are evaluating the expression `b`, with the
@@ -147,7 +149,7 @@ Now let’s look at an example where an identifier is resolved from
147149
a scope object provided via `let()`:
148150

149151
```
150-
search(let({a: `x`}, &a), {"b": "y"}) -> "x"
152+
search(let({a: `"x"`}, &a), {"b": "y"}) -> "x"
151153
```
152154

153155
Here, we’re trying to resolve the `a` identifier. The current
@@ -167,15 +169,15 @@ Finally, let’s look at an example of parent scopes. Consider the
167169
following expression:
168170

169171
```
170-
search(let({a: `x`}, &let({b: `y`}, &{a: a, b: b, c: c})),
172+
search(let({a: `"x"`}, &let({b: `"y"`}, &{a: a, b: b, c: c})),
171173
{"c": "z"}) -> {"a": "x", "b": "y", "c": "z"}
172174
```
173175

174176
Here we have nested let calls, and the expression we are trying to
175177
evaluate is the multiselect hash `{a: a, b: b, c: c}`. The
176178
`c` identifier comes from the evaluation context `{"c": "z"}`.
177179
The `b` identifier comes from the scope object in the second `let`
178-
call: ``{b: `y`}``. And finally, here’s the lookup process for the
180+
call: ``{b: `"y"`}``. And finally, here’s the lookup process for the
179181
`a` identifier:
180182

181183

@@ -188,7 +190,7 @@ call: ``{b: `y`}``. And finally, here’s the lookup process for the
188190
* Is there a parent scope? Yes
189191

190192

191-
* Does the parent scope, ``{a: `x`}``, define `a`? Yes, `a` has
193+
* Does the parent scope, ``{a: `"x"`}``, define `a`? Yes, `a` has
192194
the value of `"x"`, so `a` is resolved as the string `"x"`.
193195

194196
### Current Node Evaluation
@@ -198,7 +200,7 @@ it is worth explicitly calling out how this works with the `let()` function
198200
and expression references. Consider the following expression:
199201

200202
```
201-
a.let({x: `x`}, &b.let({y: `y`}, &c))
203+
a.let({x: `"x"`}, &b.let({y: `"y"`}, &c))
202204
```
203205

204206
Given the input data:

0 commit comments

Comments
 (0)