Skip to content

Commit 934a562

Browse files
fix: apply feedback
1 parent be189c6 commit 934a562

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

website/docs/how-to-guides/parsing.json-strings.md

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
# Unpacking a Subtle Quirk in JsonFromString Codec
22

3-
There's a small detail in `JsonFromString` from the `io-ts-types` that is worth noting.
4-
There are three type parameters to a codec `t.Type<I, O, A>`. The third parameter
5-
determines the type that the `decode` function receives. Most other codecs have the
6-
third parameter set to `unknown`. But `JsonFromString`'s type is
7-
`t.Type<Json, string, string>`. As a result, `JsonFromString` expects a string type
8-
before passing it to `decode`. You can easily convert `JsonFromString` to
9-
`t.Type<Json, string, unknown>` using `t.string`. See the example below:
3+
There are three type parameters to a codec: `t.Type<I, O, A>`. The third parameter
4+
determines the type that the `decode` function receives. Most codecs have the third
5+
parameter set to `unknown`. However, the type for `JsonFromString` in `io-ts-types` is
6+
`t.Type<Json, string, string>`. Therefore, `JsonFromString` expects a string type before
7+
passing it to `decode`. You can easily convert `JsonFromString` to
8+
`t.Type<Json, string, unknown>` using `t.string`.
9+
10+
For example:
1011

1112
```typescript
1213
import * as t from 'io-ts';

0 commit comments

Comments
 (0)