Skip to content

Commit 69a46ad

Browse files
authored
Merge pull request #19 from NathanReb/update-readme
Update readme
2 parents f608ac4 + 866df0a commit 69a46ad

File tree

1 file changed

+20
-2
lines changed

1 file changed

+20
-2
lines changed

README.md

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ regardless.
8080

8181
#### Anti-quotation
8282

83-
You can escape regular `Yojson` expression within a payload using `[%y json_expr]`. You can use
83+
You can escape regular `Yojson` expressions within a payload using `[%y json_expr]`. You can use
8484
this to insert variables in the payload. For example:
8585

8686
```ocaml
@@ -126,7 +126,9 @@ Also note that there is no limitation on nesting such patterns but you probably
126126
that too much.
127127

128128
This is provided mostly for convenience. If you want efficient code and/or to handle complex json
129-
objects I recommend that you use `ppx_deriving_yojson` instead.
129+
objects I recommend that you use
130+
[`ppx_deriving_yojson`](https://github.com/ocaml-ppx/ppx_deriving_yojson) or
131+
[`ppx_yojson_conv`](https://github.com/janestreet/ppx_yojson_conv) instead.
130132

131133
To clarify, the following code:
132134
```ocaml
@@ -141,3 +143,19 @@ let f = function
141143
| `Assoc [("b", `Bool true); ("a", `Int 1)]
142144
) -> (1, true)
143145
```
146+
147+
#### Anti-quotation
148+
149+
You can also escape regular `Yojson` patterns in `ppx_yojson` pattern extensions' payload
150+
using `[%y? json_pat]`. You can use it to further deconstruct a `Yojson` value. For example:
151+
152+
```ocaml
153+
let f = function
154+
| [%yojson? {a = [%y? `Int i]} -> i + 1
155+
```
156+
157+
is expanded into:
158+
```ocaml
159+
let f = function
160+
| `Assoc [("a", `Int i)] -> i + 1
161+
```

0 commit comments

Comments
 (0)