Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Extensions |
|
Synopsis
- atKey :: Text -> Decoder a -> FieldsDecoder a
- atKeyOptional :: Text -> Decoder a -> FieldsDecoder (Maybe a)
- atKeyStrict :: Text -> Decoder a -> FieldsDecoder a
- atPointer :: Text -> Decoder a -> Decoder a
- bool :: Decoder Bool
- char :: Decoder Char
- double :: Decoder Double
- int :: Decoder Int
- uint :: Decoder Word
- getType :: Decoder ValueType
- list :: Decoder a -> Decoder [a]
- nullable :: Decoder a -> Decoder (Maybe a)
- object :: FieldsDecoder a -> Decoder a
- objectAsKeyValues :: (Text -> Decoder k) -> Decoder v -> Decoder [(k, v)]
- objectAsMap :: Ord k => (Text -> Decoder k) -> Decoder v -> Decoder (Map k v)
- objectAsMapExcluding :: Ord k => [Text] -> (Text -> Decoder k) -> Decoder v -> Decoder (Map k v)
- parseScientific :: Text -> Decoder Scientific
- scientific :: Decoder Scientific
- string :: Decoder String
- text :: Decoder Text
- listOfDouble :: Decoder [Double]
- listOfInt :: Decoder [Int]
- isNull :: Decoder Bool
- vector :: Vector v a => Decoder a -> Decoder (v a)
- withBool :: (Bool -> Decoder a) -> Decoder a
- withDouble :: (Double -> Decoder a) -> Decoder a
- withInt :: (Int -> Decoder a) -> Decoder a
- withObjectAsMap :: Ord k => (Text -> Decoder k) -> Decoder v -> (Map k v -> Decoder a) -> Decoder a
- withRawByteString :: (ByteString -> Decoder a) -> Decoder a
- withRawText :: (Text -> Decoder a) -> Decoder a
- withScientific :: (Scientific -> Decoder a) -> Decoder a
- withString :: (String -> Decoder a) -> Decoder a
- withText :: (Text -> Decoder a) -> Decoder a
- withType :: (ValueType -> Decoder a) -> Decoder a
- withVector :: Vector v a => Decoder a -> (v a -> Decoder a) -> Decoder a
Documentation
atKey :: Text -> Decoder a -> FieldsDecoder a Source #
Find an object field by key, where an exception is thrown if the key is missing.
atKeyOptional :: Text -> Decoder a -> FieldsDecoder (Maybe a) Source #
Find an object field by key, where Nothing is returned if the key is missing.
atKeyStrict :: Text -> Decoder a -> FieldsDecoder a Source #
Uses find_field, which means if you access a field out-of-order this will throw an exception. It also cannot support optional fields.
atPointer :: Text -> Decoder a -> Decoder a Source #
Decode a value at the particular JSON pointer following RFC 6901. Be careful where you use this because it rewinds the document on each successive call.
decodeEither (atPointer "/statuses/99" decodeObject) input
nullable :: Decoder a -> Decoder (Maybe a) Source #
Transforms a parser to return Nothing when the value is null.
:: (Text -> Decoder k) | Parses a Text key in the Decoder monad. JSON keys are always text. |
-> Decoder v | Decoder for the field value. |
-> Decoder [(k, v)] |
Parse an object into a homogenous list of key-value tuples.
:: Ord k | |
=> (Text -> Decoder k) | Parses a Text key in the Decoder monad. JSON keys are always text. |
-> Decoder v | Decoder for the field value. |
-> Decoder (Map k v) |
Parse an object into a strict Map
.
:: Ord k | |
=> [Text] | List of field names to exclude. |
-> (Text -> Decoder k) | Parses a Text key in the Decoder monad. JSON keys are always text. |
-> Decoder v | Decoder for the field value. |
-> Decoder (Map k v) |
Parse an object into a strict Map
.
Skips any fields in the given list, which adds a slight performance penalty.
parseScientific :: Text -> Decoder Scientific Source #
Parse a Scientific from UTF-8 text.
scientific :: Decoder Scientific Source #
Parse a Scientific from a Value.
string :: Decoder String Source #
Parse a JSON string into a Haskell String.
For best performance you should use text
instead.
listOfDouble :: Decoder [Double] Source #
Is more efficient by looping in C++ instead of Haskell.
vector :: Vector v a => Decoder a -> Decoder (v a) Source #
Parse a homogenous JSON array into a generic Vector
.
withBool :: (Bool -> Decoder a) -> Decoder a Source #
Helper to work with a Bool parsed from a Value.
withDouble :: (Double -> Decoder a) -> Decoder a Source #
Helper to work with a Double parsed from a Value.
withRawByteString :: (ByteString -> Decoder a) -> Decoder a Source #
Helper to work with the raw ByteString of the JSON token parsed from the given Value.
withRawText :: (Text -> Decoder a) -> Decoder a Source #
Helper to work with the raw ByteString of the JSON token parsed from the given Value.
withScientific :: (Scientific -> Decoder a) -> Decoder a Source #
withString :: (String -> Decoder a) -> Decoder a Source #
Helper to work with a String parsed from a Value.