| Copyright | (c) 2015-2016 Bryan O'Sullivan |
|---|---|
| License | BSD3 |
| Maintainer | Bryan O'Sullivan <bos@serpentine.com> |
| Stability | experimental |
| Portability | portable |
| Safe Haskell | None |
| Language | Haskell2010 |
Data.Aeson.Internal
Description
Internal types and functions.
Note: all declarations in this module are unstable, and prone to being changed at any time.
Synopsis
- data IResult a
- data JSONPathElement
- type JSONPath = [JSONPathElement]
- (<?>) :: Parser a -> JSONPathElement -> Parser a
- formatError :: JSONPath -> String -> String
- ifromJSON :: FromJSON a => Value -> IResult a
- iparse :: (a -> Parser b) -> a -> IResult b
Documentation
The internal result of running a Parser.
Instances
| Monad IResult Source # | |
| Functor IResult Source # | |
| MonadFail IResult Source # | |
Defined in Data.Aeson.Types.Internal | |
| Applicative IResult Source # | |
| Foldable IResult Source # | |
Defined in Data.Aeson.Types.Internal Methods fold :: Monoid m => IResult m -> m # foldMap :: Monoid m => (a -> m) -> IResult a -> m # foldr :: (a -> b -> b) -> b -> IResult a -> b # foldr' :: (a -> b -> b) -> b -> IResult a -> b # foldl :: (b -> a -> b) -> b -> IResult a -> b # foldl' :: (b -> a -> b) -> b -> IResult a -> b # foldr1 :: (a -> a -> a) -> IResult a -> a # foldl1 :: (a -> a -> a) -> IResult a -> a # elem :: Eq a => a -> IResult a -> Bool # maximum :: Ord a => IResult a -> a # minimum :: Ord a => IResult a -> a # | |
| Traversable IResult Source # | |
| Alternative IResult Source # | |
| MonadPlus IResult Source # | |
| Eq a => Eq (IResult a) Source # | |
| Show a => Show (IResult a) Source # | |
| Semigroup (IResult a) Source # | |
| Monoid (IResult a) Source # | |
| NFData a => NFData (IResult a) Source # | |
Defined in Data.Aeson.Types.Internal | |
data JSONPathElement Source #
Elements of a JSON path used to describe the location of an error.
Constructors
| Key Text | JSON path element of a key into an object, "object.key". |
| Index !Int | JSON path element of an index into an array, "array[index]". |
Instances
| Eq JSONPathElement Source # | |
Defined in Data.Aeson.Types.Internal Methods (==) :: JSONPathElement -> JSONPathElement -> Bool # (/=) :: JSONPathElement -> JSONPathElement -> Bool # | |
| Ord JSONPathElement Source # | |
Defined in Data.Aeson.Types.Internal Methods compare :: JSONPathElement -> JSONPathElement -> Ordering # (<) :: JSONPathElement -> JSONPathElement -> Bool # (<=) :: JSONPathElement -> JSONPathElement -> Bool # (>) :: JSONPathElement -> JSONPathElement -> Bool # (>=) :: JSONPathElement -> JSONPathElement -> Bool # max :: JSONPathElement -> JSONPathElement -> JSONPathElement # min :: JSONPathElement -> JSONPathElement -> JSONPathElement # | |
| Show JSONPathElement Source # | |
Defined in Data.Aeson.Types.Internal Methods showsPrec :: Int -> JSONPathElement -> ShowS # show :: JSONPathElement -> String # showList :: [JSONPathElement] -> ShowS # | |
| NFData JSONPathElement Source # | |
Defined in Data.Aeson.Types.Internal Methods rnf :: JSONPathElement -> () # | |
type JSONPath = [JSONPathElement] Source #
(<?>) :: Parser a -> JSONPathElement -> Parser a Source #
Add JSON Path context to a parser
When parsing a complex structure, it helps to annotate (sub)parsers with context, so that if an error occurs, you can find its location.
withObject "Person" $ \o -> Person <$> o .: "name" <?> Key "name" <*> o .: "age" <?> Key "age"
(Standard methods like '(.:)' already do this.)
With such annotations, if an error occurs, you will get a JSON Path location of that error.
Since 0.10
formatError :: JSONPath -> String -> String Source #
Annotate an error message with a JSONPath error location.