aeson-2.2.1.0: Fast JSON parsing and encoding
Safe HaskellNone
LanguageHaskell2010

Data.Aeson.Encoding.Internal

Synopsis

Encoding

newtype Encoding' tag Source #

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.

Constructors

Encoding 

Fields

  • fromEncoding :: Builder

    Acquire the underlying bytestring builder.

Instances

Instances details
KeyValue Encoding Series Source # 
Instance details

Defined in Data.Aeson.Types.ToJSON

Methods

(.=) :: ToJSON v => Key -> v -> Series Source #

explicitToField :: (v -> Encoding) -> Key -> v -> Series Source #

KeyValueOmit Encoding Series Source # 
Instance details

Defined in Data.Aeson.Types.ToJSON

Methods

(.?=) :: ToJSON v => Key -> v -> Series Source #

explicitToFieldOmit :: (v -> Bool) -> (v -> Encoding) -> Key -> v -> Series Source #

GToJSON' Encoding arity (U1 :: Type -> Type) Source # 
Instance details

Defined in Data.Aeson.Types.ToJSON

Methods

gToJSON :: Options -> ToArgs Encoding arity a -> U1 a -> Encoding

GToJSON' Encoding arity (V1 :: Type -> Type) Source # 
Instance details

Defined in Data.Aeson.Types.ToJSON

Methods

gToJSON :: Options -> ToArgs Encoding arity a -> V1 a -> Encoding

ToJSON1 f => GToJSON' Encoding One (Rec1 f) Source # 
Instance details

Defined in Data.Aeson.Types.ToJSON

Methods

gToJSON :: Options -> ToArgs Encoding One a -> Rec1 f a -> Encoding

(EncodeProduct arity a, EncodeProduct arity b) => GToJSON' Encoding arity (a :*: b) Source # 
Instance details

Defined in Data.Aeson.Types.ToJSON

Methods

gToJSON :: Options -> ToArgs Encoding arity a0 -> (a :*: b) a0 -> Encoding

ToJSON a => GToJSON' Encoding arity (K1 i a :: Type -> Type) Source # 
Instance details

Defined in Data.Aeson.Types.ToJSON

Methods

gToJSON :: Options -> ToArgs Encoding arity a0 -> K1 i a a0 -> Encoding

(ToJSON1 f, GToJSON' Encoding One g) => GToJSON' Encoding One (f :.: g) Source # 
Instance details

Defined in Data.Aeson.Types.ToJSON

Methods

gToJSON :: Options -> ToArgs Encoding One a -> (f :.: g) a -> Encoding

IsString (Encoding' a) Source #

Since: 2.2.0.0

Instance details

Defined in Data.Aeson.Encoding.Internal

Methods

fromString :: String -> Encoding' a

Show (Encoding' a) Source # 
Instance details

Defined in Data.Aeson.Encoding.Internal

Methods

showsPrec :: Int -> Encoding' a -> ShowS

show :: Encoding' a -> String

showList :: [Encoding' a] -> ShowS

Eq (Encoding' a) Source # 
Instance details

Defined in Data.Aeson.Encoding.Internal

Methods

(==) :: Encoding' a -> Encoding' a -> Bool

(/=) :: Encoding' a -> Encoding' a -> Bool

Ord (Encoding' a) Source # 
Instance details

Defined in Data.Aeson.Encoding.Internal

Methods

compare :: Encoding' a -> Encoding' a -> Ordering

(<) :: Encoding' a -> Encoding' a -> Bool

(<=) :: Encoding' a -> Encoding' a -> Bool

(>) :: Encoding' a -> Encoding' a -> Bool

(>=) :: Encoding' a -> Encoding' a -> Bool

max :: Encoding' a -> Encoding' a -> Encoding' a

min :: Encoding' a -> Encoding' a -> Encoding' a

type Encoding = Encoding' Value Source #

Often used synonym for Encoding'.

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!

data Series Source #

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)

Constructors

Empty 
Value (Encoding' Series) 

Instances

Instances details
Monoid Series Source # 
Instance details

Defined in Data.Aeson.Encoding.Internal

Semigroup Series Source # 
Instance details

Defined in Data.Aeson.Encoding.Internal

Methods

(<>) :: Series -> Series -> Series

sconcat :: NonEmpty Series -> Series

stimes :: Integral b => b -> Series -> Series

KeyValue Encoding Series Source # 
Instance details

Defined in Data.Aeson.Types.ToJSON

Methods

(.=) :: ToJSON v => Key -> v -> Series Source #

explicitToField :: (v -> Encoding) -> Key -> v -> Series Source #

KeyValueOmit Encoding Series Source # 
Instance details

Defined in Data.Aeson.Types.ToJSON

Methods

(.?=) :: ToJSON v => Key -> v -> Series Source #

explicitToFieldOmit :: (v -> Bool) -> (v -> Encoding) -> Key -> v -> Series Source #

pairs :: Series -> Encoding Source #

Encode a series of key/value pairs, separated by commas.

pairStr :: String -> Encoding -> Series Source #

unsafePairSBS :: ShortByteString -> Encoding -> Series Source #

A variant of a pair where key is already encoded including the quotes and colon.

pair "foo" v = unsafePair "\"foo\":" v

Since: 2.0.3.0

Predicates

Encoding constructors

bool :: Bool -> Encoding Source #

text :: Text -> Encoding' a Source #

lazyText :: Text -> Encoding' a Source #

shortText :: ShortText -> Encoding' a Source #

Since: 2.0.2.0

string :: String -> Encoding' a Source #

list :: (a -> Encoding) -> [a] -> Encoding Source #

dict Source #

Arguments

:: (k -> Encoding' Key)

key encoding

-> (v -> Encoding)

value encoding

-> (forall a. (k -> v -> a -> a) -> a -> m -> a)

foldrWithKey - indexed fold

-> m

container

-> Encoding 

Encode as JSON object

tuple :: Encoding' InArray -> Encoding Source #

Encode as a tuple.

@ toEncoding (X a b c) = tuple $ toEncoding a >*< toEncoding b >*< toEncoding c

data InArray Source #

Type tag for tuples contents, see tuple.

(><) :: Encoding' a -> Encoding' a -> Encoding' a infixr 6 Source #

Decimal numbers

int8 :: Int8 -> Encoding Source #

int16 :: Int16 -> Encoding Source #

int32 :: Int32 -> Encoding Source #

int64 :: Int64 -> Encoding Source #

int :: Int -> Encoding Source #

word8 :: Word8 -> Encoding Source #

word16 :: Word16 -> Encoding Source #

word32 :: Word32 -> Encoding Source #

word64 :: Word64 -> Encoding Source #

word :: Word -> Encoding Source #

integer :: Integer -> Encoding Source #

float :: Float -> Encoding Source #

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

int8Text :: Int8 -> Encoding' a Source #

int16Text :: Int16 -> Encoding' a Source #

int32Text :: Int32 -> Encoding' a Source #

int64Text :: Int64 -> Encoding' a Source #

word8Text :: Word8 -> Encoding' a Source #

word16Text :: Word16 -> Encoding' a Source #

word32Text :: Word32 -> Encoding' a Source #

word64Text :: Word64 -> Encoding' a Source #

wordText :: Word -> Encoding' a Source #

integerText :: Integer -> Encoding' a Source #

floatText :: Float -> 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 #

Time

day :: Day -> Encoding' a Source #

month :: Month -> Encoding' a Source #

quarter :: Quarter -> Encoding' a Source #

localTime :: LocalTime -> Encoding' a Source #

utcTime :: UTCTime -> Encoding' a Source #

timeOfDay :: TimeOfDay -> Encoding' a Source #

zonedTime :: ZonedTime -> Encoding' a Source #

value

JSON tokens