Skip to content

Commit 0b0c341

Browse files
authored
add some usage info
1 parent 237bbea commit 0b0c341

File tree

1 file changed

+40
-1
lines changed

1 file changed

+40
-1
lines changed

README.md

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,52 @@
11
# json-skiff
22

3-
A streaming JSON parser.
3+
A streaming JSON Pointer locator.
44

55
1. Give it a list of JSON pointers and callbacks.
66
2. Feed it JSON.
77
3. Get notified when the target elements are seen.
88

99
Less capable, but simpler and faster than the excellent [JsonSurfer](https://github.com/wanglingsong/JsonSurfer) library.
1010

11+
## Usage
12+
13+
### Selecting array elements
14+
15+
Normally, a `-` in a JSON Pointer refers to the last element of an array.
16+
`json-skiff` bends the rules a bit, and interprets `-` as matching _all_ array elements.
17+
18+
Consider this JSON document:
19+
20+
```json
21+
{
22+
"magicWords": [
23+
"alakazam",
24+
"xyzzy"
25+
]
26+
}
27+
```
28+
A callback associated with `/magicWords/-` is invoked a total of two times: once for `"alakazam"` and once for `"xyzzy"`.
29+
30+
The `-` does not need to be the last component of the pointer.
31+
Consider this JSON document:
32+
33+
```json
34+
{
35+
"widgets": [
36+
{
37+
"serialNumber": "123"
38+
},
39+
{
40+
"serialNumber": "XYZ"
41+
}
42+
]
43+
}
44+
```
45+
46+
A callback associated with `/widgets/-/serialNumber` is invoked a total of two times: once for `"123"` and once for `"XYZ"`.
47+
48+
49+
## FAQ
1150

1251
### Is this library an officially supported Couchbase product?
1352

0 commit comments

Comments
 (0)