clarify filter usage
The current paragraph is not complete, since a digit is not a special character.
Changing it to:
If the key contains special characters or starts with a digit,
you need to surround it with double quotes like this:
`."foo$"`, or else `.["foo$"]`.
This commit is contained in:
4 files changed
+16
-14
No files matched your search
@@ -317,8 +317,9 @@ sections:
|
|||||||
is, keys that are all made of alphanumeric characters and
|
is, keys that are all made of alphanumeric characters and
|
||||||
underscore, and which do not start with a digit.
|
underscore, and which do not start with a digit.
|
||||||
|
|
||||||
If the key contains special characters, you need to surround
|
If the key contains special characters or starts with a digit,
|
||||||
it with double quotes like this: `."foo$"`, or else `.["foo$"]`.
|
you need to surround it with double quotes like this:
|
||||||
|
`."foo$"`, or else `.["foo$"]`.
|
||||||
|
|
||||||
For example `.["foo::bar"]` and `.["foo.bar"]` work while
|
For example `.["foo::bar"]` and `.["foo.bar"]` work while
|
||||||
`.foo::bar` does not, and `.foo.bar` means `.["foo"].["bar"]`.
|
`.foo::bar` does not, and `.foo.bar` means `.["foo"].["bar"]`.
|
||||||
@@ -2535,7 +2536,7 @@ sections:
|
|||||||
|
|
||||||
- title: 'Destructuring Alternative Operator: `?//`'
|
- title: 'Destructuring Alternative Operator: `?//`'
|
||||||
body: |
|
body: |
|
||||||
|
|
||||||
The destructuring alternative operator provides a concise mechanism
|
The destructuring alternative operator provides a concise mechanism
|
||||||
for destructuring an input that can take one of several forms.
|
for destructuring an input that can take one of several forms.
|
||||||
|
|
||||||
@@ -2544,10 +2545,10 @@ sections:
|
|||||||
the first event for each resource. The API (having been clumsily
|
the first event for each resource. The API (having been clumsily
|
||||||
converted from XML) will only wrap the events in an array if the resource
|
converted from XML) will only wrap the events in an array if the resource
|
||||||
has multiple events:
|
has multiple events:
|
||||||
|
|
||||||
{"resources": [{"id": 1, "kind": "widget", "events": {"action": "create", "user_id": 1, "ts": 13}},
|
{"resources": [{"id": 1, "kind": "widget", "events": {"action": "create", "user_id": 1, "ts": 13}},
|
||||||
{"id": 2, "kind": "widget", "events": [{"action": "create", "user_id": 1, "ts": 14}, {"action": "destroy", "user_id": 1, "ts": 15}]}]}
|
{"id": 2, "kind": "widget", "events": [{"action": "create", "user_id": 1, "ts": 14}, {"action": "destroy", "user_id": 1, "ts": 15}]}]}
|
||||||
|
|
||||||
We can use the destructuring alternative operator to handle this structural change simply:
|
We can use the destructuring alternative operator to handle this structural change simply:
|
||||||
|
|
||||||
.resources[] as {$id, $kind, events: {$user_id, $ts}} ?// {$id, $kind, events: [{$user_id, $ts}]} | {$user_id, $kind, $id, $ts}
|
.resources[] as {$id, $kind, events: {$user_id, $ts}} ?// {$id, $kind, events: [{$user_id, $ts}]} | {$user_id, $kind, $id, $ts}
|
||||||
|
|||||||
@@ -212,8 +212,8 @@ sections:
|
|||||||
JSON object (aka dictionary or hash) as input, it produces
|
JSON object (aka dictionary or hash) as input, it produces
|
||||||
the value at the key "foo", or null if there's none present.
|
the value at the key "foo", or null if there's none present.
|
||||||
|
|
||||||
If the key contains special characters, you need to surround
|
If the key contains special characters or starts with a digit,
|
||||||
it with double quotes like this: `."foo$"`.
|
you need to surround it with double quotes like this: `."foo$"`.
|
||||||
|
|
||||||
A filter of the form `.foo.bar` is equivalent to `.foo|.bar`.
|
A filter of the form `.foo.bar` is equivalent to `.foo|.bar`.
|
||||||
|
|
||||||
|
|||||||
@@ -278,8 +278,8 @@ sections:
|
|||||||
JSON object (aka dictionary or hash) as input, it produces
|
JSON object (aka dictionary or hash) as input, it produces
|
||||||
the value at the key "foo", or null if there's none present.
|
the value at the key "foo", or null if there's none present.
|
||||||
|
|
||||||
If the key contains special characters, you need to surround
|
If the key contains special characters or starts with a digit,
|
||||||
it with double quotes like this: `."foo$"`.
|
you need to surround it with double quotes like this: `."foo$"`.
|
||||||
|
|
||||||
A filter of the form `.foo.bar` is equivalent to `.foo|.bar`.
|
A filter of the form `.foo.bar` is equivalent to `.foo|.bar`.
|
||||||
|
|
||||||
|
|||||||
@@ -310,8 +310,9 @@ sections:
|
|||||||
is, keys that are all made of alphanumeric characters and
|
is, keys that are all made of alphanumeric characters and
|
||||||
underscore, and which do not start with a digit.
|
underscore, and which do not start with a digit.
|
||||||
|
|
||||||
If the key contains special characters, you need to surround
|
If the key contains special characters or starts with a digit,
|
||||||
it with double quotes like this: `."foo$"`, or else `.["foo$"]`.
|
you need to surround it with double quotes like this:
|
||||||
|
`."foo$"`, or else `.["foo$"]`.
|
||||||
|
|
||||||
For example `.["foo::bar"]` and `.["foo.bar"]` work while
|
For example `.["foo::bar"]` and `.["foo.bar"]` work while
|
||||||
`.foo::bar` does not, and `.foo.bar` means `.["foo"].["bar"]`.
|
`.foo::bar` does not, and `.foo.bar` means `.["foo"].["bar"]`.
|
||||||
@@ -2512,7 +2513,7 @@ sections:
|
|||||||
|
|
||||||
- title: 'Destructuring Alternative Operator: `?//`'
|
- title: 'Destructuring Alternative Operator: `?//`'
|
||||||
body: |
|
body: |
|
||||||
|
|
||||||
The destructuring alternative operator provides a concise mechanism
|
The destructuring alternative operator provides a concise mechanism
|
||||||
for destructuring an input that can take one of several forms.
|
for destructuring an input that can take one of several forms.
|
||||||
|
|
||||||
@@ -2521,10 +2522,10 @@ sections:
|
|||||||
the first event for each resource. The API (having been clumsily
|
the first event for each resource. The API (having been clumsily
|
||||||
converted from XML) will only wrap the events in an array if the resource
|
converted from XML) will only wrap the events in an array if the resource
|
||||||
has multiple events:
|
has multiple events:
|
||||||
|
|
||||||
{"resources": [{"id": 1, "kind": "widget", "events": {"action": "create", "user_id": 1, "ts": 13}},
|
{"resources": [{"id": 1, "kind": "widget", "events": {"action": "create", "user_id": 1, "ts": 13}},
|
||||||
{"id": 2, "kind": "widget", "events": [{"action": "create", "user_id": 1, "ts": 14}, {"action": "destroy", "user_id": 1, "ts": 15}]}]}
|
{"id": 2, "kind": "widget", "events": [{"action": "create", "user_id": 1, "ts": 14}, {"action": "destroy", "user_id": 1, "ts": 15}]}]}
|
||||||
|
|
||||||
We can use the destructuring alternative operator to handle this structural change simply:
|
We can use the destructuring alternative operator to handle this structural change simply:
|
||||||
|
|
||||||
.resources[] as {$id, $kind, events: {$user_id, $ts}} ?// {$id, $kind, events: [{$user_id, $ts}]} | {$user_id, $kind, $id, $ts}
|
.resources[] as {$id, $kind, events: {$user_id, $ts}} ?// {$id, $kind, events: [{$user_id, $ts}]} | {$user_id, $kind, $id, $ts}
|
||||||
|
|||||||
Reference in new issue
Block a user