Skip to content

Commit 1ed9b61

Browse files
committed
added a builder for CborPath struct
1 parent ff00374 commit 1ed9b61

File tree

12 files changed

+891
-988
lines changed

12 files changed

+891
-988
lines changed

README.md

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,16 @@ CBORPath is an adaptation of JSONPath to [CBOR](https://www.rfc-editor.org/rfc/r
1212

1313
| JSONPath | CBORPath | Description |
1414
|---------------------|-------------------------|-------------------------------------------------------------------------------------------------------------------------|
15-
| `$` | `"$"` | [root node identifier](#root-identifier) |
16-
| `@` | `"@"` | [current node identifier](#filter-selector) (valid only within filter selectors) |
17-
| `[<selectors>]` | `[<selectors>]` | [child segment](#child-segment) selects zero or more children of a node; contains one or more selectors, separated by commas |
18-
| `..[<selectors>]` | `{"..": [<selectors>]}` | [descendant segment](#descendant-segment): selects zero or more descendants of a node; contains one or more selectors, separated by commas |
19-
| `'name'` | `<CBOR Text>`<br>`<CBOR Bytes>`<br>`<CBOR Integer>`<br>`<CBOR Float>`<br>`<CBOR Boolean>`<br>`<CBOR Null>` | [key selector](#key-selector): selects a child of a CBOR Map based on the child key |
20-
| `*` | `"*"` | [wildcard selector](#key-selector): selects all children of a node |
21-
| `3` | `{"#": <index> }` | [index selector](#index-selector): selects an indexed child of an array (from 0) |
22-
| `0:100:5` | `{":": [<start>, <end>, <step>]}` | [array slice selector](#slice): start:end:step for arrays |
23-
| `?<expr>` | `{"?": <expr>}` | [filter selector](#filter-selector): selects particular children using a boolean expression |
24-
| `length(@.foo)` | `{"length": ["@", "foo"]}` | [function extension](#fnex): invokes a function in a filter expression |
15+
| `$` | `"$"` | root node identifier |
16+
| `@` | `"@"` | current node identifier (valid only within filter selectors) |
17+
| `[<selectors>]` | `[<selectors>]` | child segment: selects zero or more children of a node; contains one or more selectors, separated by commas |
18+
| `..[<selectors>]` | `{"..": [<selectors>]}` | descendant segment: selects zero or more descendants of a node; contains one or more selectors, separated by commas |
19+
| `'name'` | `<CBOR Text>`<br>`<CBOR Bytes>`<br>`<CBOR Integer>`<br>`<CBOR Float>`<br>`<CBOR Boolean>`<br>`<CBOR Null>` | key selector: selects a child of a CBOR Map based on the child key |
20+
| `*` | `{"*": 1}` | wildcard selector: selects all children of a node |
21+
| `3` | `{"#": <index> }` | index selector: selects an indexed child of an array (from 0) |
22+
| `0:100:5` | `{":": [<start>, <end>, <step>]}` | array slice selector: start:end:step for arrays |
23+
| `?<expr>` | `{"?": <expr>}` | filter selector: selects particular children using a boolean expression |
24+
| `length(@.foo)` | `{"length": ["@", "foo"]}` | function extension: invokes a function in a filter expression |
2525

2626
## Examples
2727

@@ -67,13 +67,13 @@ This table shows some CBORPath queries that might be applied to this example and
6767

6868
| JSONPath | CBORPath | Intended result |
6969
|---------------------------------|------------------------------------------------------|---------------------------------------------------------------|
70-
| `$.store.book[*].author` | `["$", "store", "book", "*", "author"]` | the authors of all books in the store |
70+
| `$.store.book[*].author` | `["$", "store", "book", {"*": 1}, "author"]` | the authors of all books in the store |
7171
| `$..author` | `["$", {"..": "author"}]` | all authors |
72-
| `$.store.*` | `["$", "store", "*"]` | all things in store, which are some books and a red bicycle |
72+
| `$.store.*` | `["$", "store", {"*": 1}]` | all things in store, which are some books and a red bicycle |
7373
| `$.store..price` | `["$", "store", {"..": "price"}]` | the prices of everything in the store |
7474
| `$..book[2]` | `["$", {"..": ["book", {"#": 2}]}]` | the third book |
7575
| `$..book[-1]` | `["$", {"..": ["book", {"#": -1}]}]` | the last book in order |
7676
| `$..book[0,1]`<br>`$..book[:2]` | `["$", {"..": ["book", [{"#": 0}, {"#": 1}]]}]`<br>`["$", {"..": ["book", {":": [0, 1, 1]}]}]` | the first two books |
7777
| `$..book[?(@.isbn)]` | `["$", {"..": {"?": ["@", "isbn"]}}]` | all books with an ISBN number |
7878
| `$..book[?(@.price<10)]` | `["$", {"..": {"?": {"<": [["@", "price"], 10]}}}]` | all books cheaper than 10 |
79-
| `$..*` | `["$": {"..": *}]` | all member values and array elements contained in input value |
79+
| `$..*` | `["$": {"..": {"*": 1}}]` | all member values and array elements contained in input value |

0 commit comments

Comments
 (0)