Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
AesonValueParser
Synopsis
- data Value a
- run :: Value a -> Value -> Either Error a
- runWithTextError :: Value a -> Value -> Either Text a
- runAsValueParser :: Value a -> Value -> Parser a
- data Error = Error [Text] Text
- parseByteString :: Value a -> ByteString -> Either Text a
- object :: Object a -> Value a
- array :: Array a -> Value a
- null :: Value ()
- nullable :: Value a -> Value (Maybe a)
- nullableMonoid :: Monoid a => Value a -> Value a
- string :: String a -> Value a
- number :: Number a -> Value a
- bool :: Value Bool
- fromJSON :: FromJSON a => Value a
- data String a
- text :: String Text
- mappedText :: [(Text, a)] -> String a
- narrowedText :: (Text -> Maybe a) -> String a
- matchedText :: (Text -> Either Text a) -> String a
- attoparsedText :: Parser a -> String a
- megaparsedText :: Parsec Void Text a -> String a
- data Number a
- scientific :: Number Scientific
- integer :: (Integral a, Bounded a) => Number a
- floating :: RealFloat a => Number a
- matchedScientific :: (Scientific -> Either Text a) -> Number a
- matchedInteger :: (Integral integer, Bounded integer) => (integer -> Either Text a) -> Number a
- matchedFloating :: RealFloat floating => (floating -> Either Text a) -> Number a
- data Object a
- field :: Text -> Value a -> Object a
- oneOfFields :: [Text] -> Value a -> Object a
- fieldMap :: Hashable a => String a -> Value b -> Object (HashMap a b)
- foldlFields :: (state -> key -> field -> state) -> state -> String key -> Value field -> Object state
- fieldsAmount :: Object Int
- data Array a
- element :: Int -> Value a -> Array a
- elementVector :: Value a -> Array (Vector a)
- elementList :: Value a -> Array [a]
- foldlElements :: (state -> Int -> element -> state) -> state -> Value element -> Array state
- foldrElements :: (Int -> element -> state -> state) -> state -> Value element -> Array state
- elementsAmount :: Array Int
Documentation
JSON Value
AST parser.
Its Alternative
instance implements the logic of choosing between the possible types of JSON values.
Instances
Alternative Value Source # | Implements the logic of choosing between the possible types of JSON values. If you have multiple parsers of the same type of JSON value composed, only the leftmost will be affective. The errors from deeper parsers do not trigger the alternation, instead they get propagated to the top. |
Applicative Value Source # | |
Functor Value Source # | |
runAsValueParser :: Value a -> Value -> Parser a Source #
Convert into a function directly applicable as definition
of parseJSON
.
Here's an example of how it can be used:
data Artist = Artist { artistName :: Text, artistGenres :: [Text] } instanceFromJSON
Artist whereparseJSON
=runAsValueParser
$object
$ do name <-field
"name" $string
text
genres <-field
"genres" $array
$elementList
$string
text
return $ Artist name genres
parseByteString :: Value a -> ByteString -> Either Text a Source #
Value parsers
String parsers
mappedText :: [(Text, a)] -> String a Source #
attoparsedText :: Parser a -> String a Source #
Number parsers
matchedScientific :: (Scientific -> Either Text a) -> Number a Source #
matchedInteger :: (Integral integer, Bounded integer) => (integer -> Either Text a) -> Number a Source #
Object parsers
JSON Value
parser.
foldlFields :: (state -> key -> field -> state) -> state -> String key -> Value field -> Object state Source #
fieldsAmount :: Object Int Source #
Array parsers
JSON Value
parser.
elementList :: Value a -> Array [a] Source #
foldlElements :: (state -> Int -> element -> state) -> state -> Value element -> Array state Source #