| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Aeson.ValueParser
Description
A parser DSL for the "aeson" model of the JSON tree.
Synopsis
- data Value a
- run :: Value a -> Value -> Either Error a
- data Error = Error [Text] Text
- object :: Object a -> Value a
- array :: Array a -> Value a
- null :: Value ()
- nullable :: Value a -> Value (Maybe a)
- string :: Value Text
- stringAsBytes :: Value ByteString
- number :: Value Scientific
- numberAsInt :: Value Int
- bool :: Value Bool
- fromJSON :: FromJSON a => Value a
- data Object a
- field :: Text -> Value a -> Object a
- oneOfFields :: [Text] -> Value a -> Object a
- fieldOr :: Text -> Value a -> Object a -> Object a
- oneOfFieldsOr :: [Text] -> Value a -> Object a -> Object a
- possibleField :: Text -> Value a -> Object (Maybe a)
- oneOfPossibleFields :: [Text] -> Value a -> Object (Maybe a)
- fieldMap :: Value a -> Object (HashMap Text a)
- foldlFields :: (state -> Text -> field -> state) -> state -> Value field -> Object state
- data Array a
- element :: Int -> Value a -> Array a
- elementOr :: Int -> Value a -> Array a -> Array a
- possibleElement :: Int -> Value a -> Array (Maybe a)
- elementVector :: Value a -> Array (Vector a)
- foldlElements :: (state -> Int -> element -> state) -> state -> Value element -> Array state
- foldrElements :: (Int -> element -> state -> state) -> state -> Value element -> Array state
Documentation
A JSON Value parser.
Instances
| IsString Error Source # | |
Defined in Aeson.ValueParser.Error Methods fromString :: String -> Error # | |
| Semigroup Error Source # | |
| Monoid Error Source # | |
| MonadError Error Array Source # | |
Defined in Aeson.ValueParser | |
| MonadError Error Object Source # | |
Defined in Aeson.ValueParser | |
| MonadError Error Value Source # | |
Defined in Aeson.ValueParser | |
Value parsers
number :: Value Scientific Source #
numberAsInt :: Value Int Source #
Object parsers
A JSON Value parser.
Applies the value parser to the existing field, propagating its errors accordingly.
Only if the field does not exist, it executes Alternative branch.
IOW, it won't execute Alternative branch if Field parser fails.
This is what distinguishes fieldOr name parser from the seemingly same mplus (field name parser)
oneOfFieldsOr :: [Text] -> Value a -> Object a -> Object a Source #
Same as fieldOr,
with the only difference that it enumerates the provided list of field names
parsing the first existing one.
oneOfPossibleFields :: [Text] -> Value a -> Object (Maybe a) Source #
Same as possibleField,
with the only difference that it enumerates the provided list of field names
parsing the first existing one.
Array parsers
A JSON Value parser.