Skip to content

Instantly share code, notes, and snippets.

@kofno
Created June 25, 2017 01:11
Show Gist options
  • Select an option

  • Save kofno/57f923ab0bd52688469871a933f7f51b to your computer and use it in GitHub Desktop.

Select an option

Save kofno/57f923ab0bd52688469871a933f7f51b to your computer and use it in GitHub Desktop.
The at decoder
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