Copyright | (c) 2015-2016 Bryan O'Sullivan |
---|---|
License | BSD3 |
Maintainer | Bryan O'Sullivan <bos@serpentine.com> |
Stability | experimental |
Portability | portable |
Safe Haskell | Safe-Inferred |
Language | Haskell2010 |
Deprecated: All contents of this module are exported from Data.Aeson.Types module. This module will be removed in the next major aeson version.
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
data JSONPathElement Source #
Elements of a JSON path used to describe the location of an error.
Key Key | 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
Show JSONPathElement Source # | |
Defined in Data.Aeson.Types.Internal showsPrec :: Int -> JSONPathElement -> ShowS # show :: JSONPathElement -> String # showList :: [JSONPathElement] -> ShowS # | |
NFData JSONPathElement Source # | |
Defined in Data.Aeson.Types.Internal rnf :: JSONPathElement -> () # | |
Eq JSONPathElement Source # | |
Defined in Data.Aeson.Types.Internal (==) :: JSONPathElement -> JSONPathElement -> Bool # (/=) :: JSONPathElement -> JSONPathElement -> Bool # | |
Ord JSONPathElement Source # | |
Defined in Data.Aeson.Types.Internal compare :: JSONPathElement -> JSONPathElement -> Ordering # (<) :: JSONPathElement -> JSONPathElement -> Bool # (<=) :: JSONPathElement -> JSONPathElement -> Bool # (>) :: JSONPathElement -> JSONPathElement -> Bool # (>=) :: JSONPathElement -> JSONPathElement -> Bool # max :: JSONPathElement -> JSONPathElement -> JSONPathElement # min :: JSONPathElement -> JSONPathElement -> 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.