Safe Haskell | None |
---|---|
Language | Haskell2010 |
Synopsis
- type Encoding = Encoding' Value
- data Encoding' tag
- encodingToLazyByteString :: Encoding' a -> ByteString
- fromEncoding :: Encoding' tag -> Builder
- unsafeToEncoding :: Builder -> Encoding' a
- data Series
- pairs :: Series -> Encoding
- pair :: Key -> Encoding -> Series
- pairStr :: String -> Encoding -> Series
- pair' :: Encoding' Key -> Encoding -> Series
- nullEncoding :: Encoding' a -> Bool
- emptyArray_ :: Encoding
- emptyObject_ :: Encoding
- text :: Text -> Encoding' a
- lazyText :: Text -> Encoding' a
- shortText :: ShortText -> Encoding' a
- string :: String -> Encoding' a
- list :: (a -> Encoding ) -> [a] -> Encoding
- dict :: (k -> Encoding' Key ) -> (v -> Encoding ) -> ( forall a. (k -> v -> a -> a) -> a -> m -> a) -> m -> Encoding
- null_ :: Encoding
- bool :: Bool -> Encoding
- int8 :: Int8 -> Encoding
- int16 :: Int16 -> Encoding
- int32 :: Int32 -> Encoding
- int64 :: Int64 -> Encoding
- int :: Int -> Encoding
- word8 :: Word8 -> Encoding
- word16 :: Word16 -> Encoding
- word32 :: Word32 -> Encoding
- word64 :: Word64 -> Encoding
- word :: Word -> Encoding
- integer :: Integer -> Encoding
- float :: Float -> Encoding
- double :: Double -> Encoding
- scientific :: Scientific -> Encoding
- int8Text :: Int8 -> Encoding' a
- int16Text :: Int16 -> Encoding' a
- int32Text :: Int32 -> Encoding' a
- int64Text :: Int64 -> Encoding' a
- intText :: Int -> Encoding' a
- word8Text :: Word8 -> Encoding' a
- word16Text :: Word16 -> Encoding' a
- word32Text :: Word32 -> Encoding' a
- word64Text :: Word64 -> Encoding' a
- wordText :: Word -> Encoding' a
- integerText :: Integer -> Encoding' a
- floatText :: Float -> Encoding' a
- doubleText :: Double -> Encoding' a
- scientificText :: Scientific -> Encoding' a
- day :: Day -> Encoding' a
- month :: Month -> Encoding' a
- quarter :: Quarter -> Encoding' a
- localTime :: LocalTime -> Encoding' a
- utcTime :: UTCTime -> Encoding' a
- timeOfDay :: TimeOfDay -> Encoding' a
- zonedTime :: ZonedTime -> Encoding' a
- value :: Value -> Encoding
Encoding
An encoding of a JSON value.
tag
represents which kind of JSON the Encoding is encoding to,
we reuse
Text
and
Value
as tags here.
Instances
GToJSON' Encoding arity ( U1 :: Type -> Type ) Source # | |
ToJSON1 f => GToJSON' Encoding One ( Rec1 f) Source # | |
(EncodeProduct arity a, EncodeProduct arity b) => GToJSON' Encoding arity (a :*: b) Source # | |
ToJSON a => GToJSON' Encoding arity ( K1 i a :: Type -> Type ) Source # | |
( ToJSON1 f, GToJSON' Encoding One g) => GToJSON' Encoding One (f :.: g) Source # | |
Eq ( Encoding' a) Source # | |
Ord ( Encoding' a) Source # | |
Defined in Data.Aeson.Encoding.Internal compare :: Encoding' a -> Encoding' a -> Ordering Source # (<) :: Encoding' a -> Encoding' a -> Bool Source # (<=) :: Encoding' a -> Encoding' a -> Bool Source # (>) :: Encoding' a -> Encoding' a -> Bool Source # (>=) :: Encoding' a -> Encoding' a -> Bool Source # |
|
Show ( Encoding' a) Source # | |
fromEncoding :: Encoding' tag -> Builder Source #
Acquire the underlying bytestring builder.
unsafeToEncoding :: Builder -> Encoding' a Source #
Make Encoding from Builder.
Use with care! You have to make sure that the passed Builder is a valid JSON Encoding!
A series of values that, when encoded, should be separated by
commas. Since 0.11.0.0, the
.=
operator is overloaded to create
either
(Text, Value)
or
Series
. You can use Series when
encoding directly to a bytestring builder as in the following
example:
toEncoding (Person name age) = pairs ("name" .= name <> "age" .= age)
Predicates
nullEncoding :: Encoding' a -> Bool Source #
Encoding constructors
:: (k -> Encoding' Key ) |
key encoding |
-> (v -> Encoding ) |
value encoding |
-> ( forall a. (k -> v -> a -> a) -> a -> m -> a) |
|
-> m |
container |
-> Encoding |
Encode as JSON object
Decimal numbers
double :: Double -> Encoding Source #
>>>
double 42
"42.0"
>>>
double (0/0)
"null"
>>>
double (1/0)
"\"+inf\""
>>>
double (-23/0)
"\"-inf\""
scientific :: Scientific -> Encoding Source #
Decimal numbers as Text
word16Text :: Word16 -> Encoding' a Source #
word32Text :: Word32 -> Encoding' a Source #
word64Text :: Word64 -> Encoding' a Source #
integerText :: Integer -> Encoding' a Source #
doubleText :: Double -> Encoding' a Source #
>>>
doubleText 42
"\"42.0\""
>>>
doubleText (0/0)
"\"NaN\""
>>>
doubleText (1/0)
"\"+inf\""
>>>
doubleText (-23/0)
"\"-inf\""
scientificText :: Scientific -> Encoding' a Source #