Created
June 25, 2017 01:11
-
-
Save kofno/57f923ab0bd52688469871a933f7f51b to your computer and use it in GitHub Desktop.
The at decoder
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { at, number } from 'jsonous'; | |
| at(['foo', 0, 'bar'], number()).decodeAny({ foo: [{ bar: 42 }] }) | |
| // --> Ok(42) | |
| at(['foo', 1, 'bar'], number()).decodeAny({ foo: [{ bar: 42 }] }) | |
| // --> Err('Path failure: Expected to find path '["foo",1]' in {"foo":[{"bar":42}]}') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment