deriving-aeson-0.2.9: Type driven generic aeson instance customisation
Safe Haskell None
Language Haskell2010

Deriving.Aeson.Stock

Contents

Synopsis

Documentation

type Prefixed str = CustomJSON '[ FieldLabelModifier ( StripPrefix str)] Source #

Field names are prefixed by str ; strip them from JSON representation

type PrefixedSnake str = CustomJSON '[ FieldLabelModifier '[ StripPrefix str, CamelToSnake ]] Source #

Strip str prefices and convert from CamelCase to snake_case

type Snake = CustomJSON '[ FieldLabelModifier CamelToSnake ] Source #

Convert from CamelCase to snake_case

type Vanilla = CustomJSON ('[] :: [ Type ]) Source #

No customisation

Reexports

class FromJSON a Source #

A type that can be converted from JSON, with the possibility of failure.

In many cases, you can get the compiler to generate parsing code for you (see below). To begin, let's cover writing an instance by hand.

There are various reasons a conversion could fail. For example, an Object could be missing a required key, an Array could be of the wrong size, or a value could be of an incompatible type.

The basic ways to signal a failed conversion are as follows:

  • fail yields a custom error message: it is the recommended way of reporting a failure;
  • empty (or mzero ) is uninformative: use it when the error is meant to be caught by some ( <|> ) ;
  • typeMismatch can be used to report a failure when the encountered value is not of the expected JSON type; unexpected is an appropriate alternative when more than one type may be expected, or to keep the expected type implicit.

prependFailure (or modifyFailure ) add more information to a parser's error messages.

An example type and instance using typeMismatch and prependFailure :

-- Allow ourselves to write Text literals.
{-# LANGUAGE OverloadedStrings #-}

data Coord = Coord { x :: Double, y :: Double }

instance FromJSON Coord where
    parseJSON (Object v) = Coord
        <$> v .: "x"
        <*> v .: "y"

    -- We do not expect a non-Object value here.
    -- We could use empty to fail, but typeMismatch
    -- gives a much more informative error message.
    parseJSON invalid    =
        prependFailure "parsing Coord failed, "
            (typeMismatch "Object" invalid)

For this common case of only being concerned with a single type of JSON value, the functions withObject , withScientific , etc. are provided. Their use is to be preferred when possible, since they are more terse. Using withObject , we can rewrite the above instance (assuming the same language extension and data type) as:

instance FromJSON Coord where
    parseJSON = withObject "Coord" $ \v -> Coord
        <$> v .: "x"
        <*> v .: "y"

Instead of manually writing your FromJSON instance, there are two options to do it automatically:

  • Data.Aeson.TH provides Template Haskell functions which will derive an instance at compile time. The generated instance is optimized for your type so it will probably be more efficient than the following option.
  • The compiler can provide a default generic implementation for parseJSON .

To use the second, simply add a deriving Generic clause to your datatype and declare a FromJSON instance for your datatype without giving a definition for parseJSON .

For example, the previous example can be simplified to just:

{-# LANGUAGE DeriveGeneric #-}

import GHC.Generics

data Coord = Coord { x :: Double, y :: Double } deriving Generic

instance FromJSON Coord

The default implementation will be equivalent to parseJSON = genericParseJSON defaultOptions ; if you need different options, you can customize the generic decoding by defining:

customOptions = defaultOptions
                { fieldLabelModifier = map toUpper
                }

instance FromJSON Coord where
    parseJSON = genericParseJSON customOptions

Instances

Instances details
FromJSON Bool
Instance details

Defined in Data.Aeson.Types.FromJSON

FromJSON Char
Instance details

Defined in Data.Aeson.Types.FromJSON

FromJSON Double
Instance details

Defined in Data.Aeson.Types.FromJSON

FromJSON Float
Instance details

Defined in Data.Aeson.Types.FromJSON

FromJSON Int
Instance details

Defined in Data.Aeson.Types.FromJSON

FromJSON Int8
Instance details

Defined in Data.Aeson.Types.FromJSON

FromJSON Int16
Instance details

Defined in Data.Aeson.Types.FromJSON

FromJSON Int32
Instance details

Defined in Data.Aeson.Types.FromJSON

FromJSON Int64
Instance details

Defined in Data.Aeson.Types.FromJSON

FromJSON Integer

This instance includes a bounds check to prevent maliciously large inputs to fill up the memory of the target system. You can newtype Scientific and provide your own instance using withScientific if you want to allow larger inputs.

Instance details

Defined in Data.Aeson.Types.FromJSON

FromJSON Natural
Instance details

Defined in Data.Aeson.Types.FromJSON

FromJSON Ordering
Instance details

Defined in Data.Aeson.Types.FromJSON

FromJSON Word
Instance details

Defined in Data.Aeson.Types.FromJSON

FromJSON Word8
Instance details

Defined in Data.Aeson.Types.FromJSON

FromJSON Word16
Instance details

Defined in Data.Aeson.Types.FromJSON

FromJSON Word32
Instance details

Defined in Data.Aeson.Types.FromJSON

FromJSON Word64
Instance details

Defined in Data.Aeson.Types.FromJSON

FromJSON ()
Instance details

Defined in Data.Aeson.Types.FromJSON

FromJSON Scientific
Instance details

Defined in Data.Aeson.Types.FromJSON

FromJSON UTCTime
Instance details

Defined in Data.Aeson.Types.FromJSON

FromJSON Text
Instance details

Defined in Data.Aeson.Types.FromJSON

FromJSON Value
Instance details

Defined in Data.Aeson.Types.FromJSON

FromJSON DotNetTime
Instance details

Defined in Data.Aeson.Types.FromJSON

FromJSON Key
Instance details

Defined in Data.Aeson.Types.FromJSON

FromJSON Text
Instance details

Defined in Data.Aeson.Types.FromJSON

FromJSON Void
Instance details

Defined in Data.Aeson.Types.FromJSON

FromJSON Version
Instance details

Defined in Data.Aeson.Types.FromJSON

FromJSON CTime
Instance details

Defined in Data.Aeson.Types.FromJSON

FromJSON IntSet
Instance details

Defined in Data.Aeson.Types.FromJSON

FromJSON ShortText

Since: aeson-2.0.2.0

Instance details

Defined in Data.Aeson.Types.FromJSON

FromJSON ZonedTime

Supported string formats:

YYYY-MM-DD HH:MM Z YYYY-MM-DD HH:MM:SS Z YYYY-MM-DD HH:MM:SS.SSS Z

The first space may instead be a T , and the second space is optional. The Z represents UTC. The Z may be replaced with a time zone offset of the form +0000 or -08:00 , where the first two digits are hours, the : is optional and the second two digits (also optional) are minutes.

Instance details

Defined in Data.Aeson.Types.FromJSON

FromJSON LocalTime
Instance details

Defined in Data.Aeson.Types.FromJSON

FromJSON TimeOfDay
Instance details

Defined in Data.Aeson.Types.FromJSON

FromJSON CalendarDiffTime
Instance details

Defined in Data.Aeson.Types.FromJSON

FromJSON SystemTime
Instance details

Defined in Data.Aeson.Types.FromJSON

FromJSON NominalDiffTime

This instance includes a bounds check to prevent maliciously large inputs to fill up the memory of the target system. You can newtype Scientific and provide your own instance using withScientific if you want to allow larger inputs.

Instance details

Defined in Data.Aeson.Types.FromJSON

FromJSON DiffTime

This instance includes a bounds check to prevent maliciously large inputs to fill up the memory of the target system. You can newtype Scientific and provide your own instance using withScientific if you want to allow larger inputs.

Instance details

Defined in Data.Aeson.Types.FromJSON

FromJSON DayOfWeek
Instance details

Defined in Data.Aeson.Types.FromJSON

FromJSON Day
Instance details

Defined in Data.Aeson.Types.FromJSON

FromJSON CalendarDiffDays
Instance details

Defined in Data.Aeson.Types.FromJSON

FromJSON QuarterOfYear
Instance details

Defined in Data.Aeson.Types.FromJSON

FromJSON Quarter
Instance details

Defined in Data.Aeson.Types.FromJSON

FromJSON Month
Instance details

Defined in Data.Aeson.Types.FromJSON

FromJSON UUID
Instance details

Defined in Data.Aeson.Types.FromJSON

FromJSON a => FromJSON [a]
Instance details

Defined in Data.Aeson.Types.FromJSON

FromJSON a => FromJSON ( Maybe a)
Instance details

Defined in Data.Aeson.Types.FromJSON

( FromJSON a, Integral a) => FromJSON ( Ratio a)
Instance details

Defined in Data.Aeson.Types.FromJSON

FromJSON a => FromJSON ( Solo a)

Since: aeson-2.0.2.0

Instance details

Defined in Data.Aeson.Types.FromJSON

FromJSON v => FromJSON ( KeyMap v)

Since: aeson-2.0.1.0

Instance details

Defined in Data.Aeson.Types.FromJSON

FromJSON a => FromJSON ( Min a)
Instance details

Defined in Data.Aeson.Types.FromJSON

FromJSON a => FromJSON ( Max a)
Instance details

Defined in Data.Aeson.Types.FromJSON

FromJSON a => FromJSON ( First a)
Instance details

Defined in Data.Aeson.Types.FromJSON

FromJSON a => FromJSON ( Last a)
Instance details

Defined in Data.Aeson.Types.FromJSON

FromJSON a => FromJSON ( WrappedMonoid a)
Instance details

Defined in Data.Aeson.Types.FromJSON

FromJSON a => FromJSON ( Option a)
Instance details

Defined in Data.Aeson.Types.FromJSON

FromJSON a => FromJSON ( Identity a)
Instance details

Defined in Data.Aeson.Types.FromJSON

FromJSON a => FromJSON ( First a)
Instance details

Defined in Data.Aeson.Types.FromJSON

FromJSON a => FromJSON ( Last a)
Instance details

Defined in Data.Aeson.Types.FromJSON

FromJSON a => FromJSON ( Dual a)
Instance details

Defined in Data.Aeson.Types.FromJSON

FromJSON a => FromJSON ( NonEmpty a)
Instance details

Defined in Data.Aeson.Types.FromJSON

FromJSON a => FromJSON ( IntMap a)
Instance details

Defined in Data.Aeson.Types.FromJSON

FromJSON v => FromJSON ( Tree v)
Instance details

Defined in Data.Aeson.Types.FromJSON

FromJSON a => FromJSON ( Seq a)
Instance details

Defined in Data.Aeson.Types.FromJSON

( Ord a, FromJSON a) => FromJSON ( Set a)
Instance details

Defined in Data.Aeson.Types.FromJSON

FromJSON1 f => FromJSON ( Fix f)

Since: aeson-1.5.3.0

Instance details

Defined in Data.Aeson.Types.FromJSON

( FromJSON1 f, Functor f) => FromJSON ( Mu f)

Since: aeson-1.5.3.0

Instance details

Defined in Data.Aeson.Types.FromJSON

( FromJSON1 f, Functor f) => FromJSON ( Nu f)

Since: aeson-1.5.3.0

Instance details

Defined in Data.Aeson.Types.FromJSON

FromJSON a => FromJSON ( DNonEmpty a)

Since: aeson-1.5.3.0

Instance details

Defined in Data.Aeson.Types.FromJSON

FromJSON a => FromJSON ( DList a)
Instance details

Defined in Data.Aeson.Types.FromJSON

( Prim a, FromJSON a) => FromJSON ( PrimArray a)
Instance details

Defined in Data.Aeson.Types.FromJSON

FromJSON a => FromJSON ( SmallArray a)
Instance details

Defined in Data.Aeson.Types.FromJSON

FromJSON a => FromJSON ( Array a)
Instance details

Defined in Data.Aeson.Types.FromJSON

FromJSON a => FromJSON ( Maybe a)

Since: aeson-1.5.3.0

Instance details

Defined in Data.Aeson.Types.FromJSON

( Eq a, Hashable a, FromJSON a) => FromJSON ( HashSet a)
Instance details

Defined in Data.Aeson.Types.FromJSON

( Vector Vector a, FromJSON a) => FromJSON ( Vector a)
Instance details

Defined in Data.Aeson.Types.FromJSON

( Storable a, FromJSON a) => FromJSON ( Vector a)
Instance details

Defined in Data.Aeson.Types.FromJSON

( Prim a, FromJSON a) => FromJSON ( Vector a)
Instance details

Defined in Data.Aeson.Types.FromJSON

FromJSON a => FromJSON ( Vector a)
Instance details

Defined in Data.Aeson.Types.FromJSON

( FromJSON a, FromJSON b) => FromJSON ( Either a b)
Instance details

Defined in Data.Aeson.Types.FromJSON

( FromJSON a, FromJSON b) => FromJSON (a, b)
Instance details

Defined in Data.Aeson.Types.FromJSON

( FromJSONKey k, Ord k, FromJSON v) => FromJSON ( Map k v)
Instance details

Defined in Data.Aeson.Types.FromJSON

( FromJSON v, FromJSONKey k, Eq k, Hashable k) => FromJSON ( HashMap k v)
Instance details

Defined in Data.Aeson.Types.FromJSON

HasResolution a => FromJSON ( Fixed a)

This instance includes a bounds check to prevent maliciously large inputs to fill up the memory of the target system. You can newtype Scientific and provide your own instance using withScientific if you want to allow larger inputs.

Instance details

Defined in Data.Aeson.Types.FromJSON

FromJSON ( Proxy a)
Instance details

Defined in Data.Aeson.Types.FromJSON

( FromJSON a, FromJSON b) => FromJSON ( These a b)

Since: aeson-1.5.1.0

Instance details

Defined in Data.Aeson.Types.FromJSON

( FromJSON a, FromJSON b) => FromJSON ( Pair a b)

Since: aeson-1.5.3.0

Instance details

Defined in Data.Aeson.Types.FromJSON

( FromJSON a, FromJSON b) => FromJSON ( These a b)

Since: aeson-1.5.3.0

Instance details

Defined in Data.Aeson.Types.FromJSON

( FromJSON a, FromJSON b) => FromJSON ( Either a b)

Since: aeson-1.5.3.0

Instance details

Defined in Data.Aeson.Types.FromJSON

( FromJSON a, FromJSON b, FromJSON c) => FromJSON (a, b, c)
Instance details

Defined in Data.Aeson.Types.FromJSON

FromJSON a => FromJSON ( Const a b)
Instance details

Defined in Data.Aeson.Types.FromJSON

FromJSON b => FromJSON ( Tagged a b)
Instance details

Defined in Data.Aeson.Types.FromJSON

( FromJSON1 f, FromJSON1 g, FromJSON a) => FromJSON ( These1 f g a)

Since: aeson-1.5.1.0

Instance details

Defined in Data.Aeson.Types.FromJSON

( AesonOptions t, Generic a, GFromJSON Zero ( Rep a)) => FromJSON ( CustomJSON t a) Source #
Instance details

Defined in Deriving.Aeson

( FromJSON a, FromJSON b, FromJSON c, FromJSON d) => FromJSON (a, b, c, d)
Instance details

Defined in Data.Aeson.Types.FromJSON

( FromJSON1 f, FromJSON1 g, FromJSON a) => FromJSON ( Product f g a)
Instance details

Defined in Data.Aeson.Types.FromJSON

( FromJSON1 f, FromJSON1 g, FromJSON a) => FromJSON ( Sum f g a)
Instance details

Defined in Data.Aeson.Types.FromJSON

( FromJSON a, FromJSON b, FromJSON c, FromJSON d, FromJSON e) => FromJSON (a, b, c, d, e)
Instance details

Defined in Data.Aeson.Types.FromJSON

( FromJSON1 f, FromJSON1 g, FromJSON a) => FromJSON ( Compose f g a)
Instance details

Defined in Data.Aeson.Types.FromJSON

( FromJSON a, FromJSON b, FromJSON c, FromJSON d, FromJSON e, FromJSON f) => FromJSON (a, b, c, d, e, f)
Instance details

Defined in Data.Aeson.Types.FromJSON

( FromJSON a, FromJSON b, FromJSON c, FromJSON d, FromJSON e, FromJSON f, FromJSON g) => FromJSON (a, b, c, d, e, f, g)
Instance details

Defined in Data.Aeson.Types.FromJSON

Methods

parseJSON :: Value -> Parser (a, b, c, d, e, f, g) Source #

parseJSONList :: Value -> Parser [(a, b, c, d, e, f, g)] Source #

( FromJSON a, FromJSON b, FromJSON c, FromJSON d, FromJSON e, FromJSON f, FromJSON g, FromJSON h) => FromJSON (a, b, c, d, e, f, g, h)
Instance details

Defined in Data.Aeson.Types.FromJSON

Methods

parseJSON :: Value -> Parser (a, b, c, d, e, f, g, h) Source #

parseJSONList :: Value -> Parser [(a, b, c, d, e, f, g, h)] Source #

( FromJSON a, FromJSON b, FromJSON c, FromJSON d, FromJSON e, FromJSON f, FromJSON g, FromJSON h, FromJSON i) => FromJSON (a, b, c, d, e, f, g, h, i)
Instance details

Defined in Data.Aeson.Types.FromJSON

Methods

parseJSON :: Value -> Parser (a, b, c, d, e, f, g, h, i) Source #

parseJSONList :: Value -> Parser [(a, b, c, d, e, f, g, h, i)] Source #

( FromJSON a, FromJSON b, FromJSON c, FromJSON d, FromJSON e, FromJSON f, FromJSON g, FromJSON h, FromJSON i, FromJSON j) => FromJSON (a, b, c, d, e, f, g, h, i, j)
Instance details

Defined in Data.Aeson.Types.FromJSON

Methods

parseJSON :: Value -> Parser (a, b, c, d, e, f, g, h, i, j) Source #

parseJSONList :: Value -> Parser [(a, b, c, d, e, f, g, h, i, j)] Source #

( FromJSON a, FromJSON b, FromJSON c, FromJSON d, FromJSON e, FromJSON f, FromJSON g, FromJSON h, FromJSON i, FromJSON j, FromJSON k) => FromJSON (a, b, c, d, e, f, g, h, i, j, k)
Instance details

Defined in Data.Aeson.Types.FromJSON

Methods

parseJSON :: Value -> Parser (a, b, c, d, e, f, g, h, i, j, k) Source #

parseJSONList :: Value -> Parser [(a, b, c, d, e, f, g, h, i, j, k)] Source #

( FromJSON a, FromJSON b, FromJSON c, FromJSON d, FromJSON e, FromJSON f, FromJSON g, FromJSON h, FromJSON i, FromJSON j, FromJSON k, FromJSON l) => FromJSON (a, b, c, d, e, f, g, h, i, j, k, l)
Instance details

Defined in Data.Aeson.Types.FromJSON

Methods

parseJSON :: Value -> Parser (a, b, c, d, e, f, g, h, i, j, k, l) Source #

parseJSONList :: Value -> Parser [(a, b, c, d, e, f, g, h, i, j, k, l)] Source #

( FromJSON a, FromJSON b, FromJSON c, FromJSON d, FromJSON e, FromJSON f, FromJSON g, FromJSON h, FromJSON i, FromJSON j, FromJSON k, FromJSON l, FromJSON m) => FromJSON (a, b, c, d, e, f, g, h, i, j, k, l, m)
Instance details

Defined in Data.Aeson.Types.FromJSON

Methods

parseJSON :: Value -> Parser (a, b, c, d, e, f, g, h, i, j, k, l, m) Source #

parseJSONList :: Value -> Parser [(a, b, c, d, e, f, g, h, i, j, k, l, m)] Source #

( FromJSON a, FromJSON b, FromJSON c, FromJSON d, FromJSON e, FromJSON f, FromJSON g, FromJSON h, FromJSON i, FromJSON j, FromJSON k, FromJSON l, FromJSON m, FromJSON n) => FromJSON (a, b, c, d, e, f, g, h, i, j, k, l, m, n)
Instance details

Defined in Data.Aeson.Types.FromJSON

Methods

parseJSON :: Value -> Parser (a, b, c, d, e, f, g, h, i, j, k, l, m, n) Source #

parseJSONList :: Value -> Parser [(a, b, c, d, e, f, g, h, i, j, k, l, m, n)] Source #

( FromJSON a, FromJSON b, FromJSON c, FromJSON d, FromJSON e, FromJSON f, FromJSON g, FromJSON h, FromJSON i, FromJSON j, FromJSON k, FromJSON l, FromJSON m, FromJSON n, FromJSON o) => FromJSON (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o)
Instance details

Defined in Data.Aeson.Types.FromJSON

Methods

parseJSON :: Value -> Parser (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o) Source #

parseJSONList :: Value -> Parser [(a, b, c, d, e, f, g, h, i, j, k, l, m, n, o)] Source #

class ToJSON a Source #

A type that can be converted to JSON.

Instances in general must specify toJSON and should (but don't need to) specify toEncoding .

An example type and instance:

-- Allow ourselves to write Text literals.
{-# LANGUAGE OverloadedStrings #-}

data Coord = Coord { x :: Double, y :: Double }

instance ToJSON Coord where
  toJSON (Coord x y) = object ["x" .= x, "y" .= y]

  toEncoding (Coord x y) = pairs ("x" .= x <> "y" .= y)

Instead of manually writing your ToJSON instance, there are two options to do it automatically:

  • Data.Aeson.TH provides Template Haskell functions which will derive an instance at compile time. The generated instance is optimized for your type so it will probably be more efficient than the following option.
  • The compiler can provide a default generic implementation for toJSON .

To use the second, simply add a deriving Generic clause to your datatype and declare a ToJSON instance. If you require nothing other than defaultOptions , it is sufficient to write (and this is the only alternative where the default toJSON implementation is sufficient):

{-# LANGUAGE DeriveGeneric #-}

import GHC.Generics

data Coord = Coord { x :: Double, y :: Double } deriving Generic

instance ToJSON Coord where
    toEncoding = genericToEncoding defaultOptions

If on the other hand you wish to customize the generic decoding, you have to implement both methods:

customOptions = defaultOptions
                { fieldLabelModifier = map toUpper
                }

instance ToJSON Coord where
    toJSON     = genericToJSON customOptions
    toEncoding = genericToEncoding customOptions

Previous versions of this library only had the toJSON method. Adding toEncoding had two reasons:

  1. toEncoding is more efficient for the common case that the output of toJSON is directly serialized to a ByteString . Further, expressing either method in terms of the other would be non-optimal.
  2. The choice of defaults allows a smooth transition for existing users: Existing instances that do not define toEncoding still compile and have the correct semantics. This is ensured by making the default implementation of toEncoding use toJSON . This produces correct results, but since it performs an intermediate conversion to a Value , it will be less efficient than directly emitting an Encoding . (this also means that specifying nothing more than instance ToJSON Coord would be sufficient as a generically decoding instance, but there probably exists no good reason to not specify toEncoding in new instances.)

Instances

Instances details
ToJSON Bool
Instance details

Defined in Data.Aeson.Types.ToJSON

ToJSON Char
Instance details

Defined in Data.Aeson.Types.ToJSON

ToJSON Double
Instance details

Defined in Data.Aeson.Types.ToJSON

ToJSON Float
Instance details

Defined in Data.Aeson.Types.ToJSON

ToJSON Int
Instance details

Defined in Data.Aeson.Types.ToJSON

ToJSON Int8
Instance details

Defined in Data.Aeson.Types.ToJSON

ToJSON Int16
Instance details

Defined in Data.Aeson.Types.ToJSON

ToJSON Int32
Instance details

Defined in Data.Aeson.Types.ToJSON

ToJSON Int64
Instance details

Defined in Data.Aeson.Types.ToJSON

ToJSON Integer
Instance details

Defined in Data.Aeson.Types.ToJSON

ToJSON Natural
Instance details

Defined in Data.Aeson.Types.ToJSON

ToJSON Ordering
Instance details

Defined in Data.Aeson.Types.ToJSON

ToJSON Word
Instance details

Defined in Data.Aeson.Types.ToJSON

ToJSON Word8
Instance details

Defined in Data.Aeson.Types.ToJSON

ToJSON Word16
Instance details

Defined in Data.Aeson.Types.ToJSON

ToJSON Word32
Instance details

Defined in Data.Aeson.Types.ToJSON

ToJSON Word64
Instance details

Defined in Data.Aeson.Types.ToJSON

ToJSON ()
Instance details

Defined in Data.Aeson.Types.ToJSON

ToJSON Scientific
Instance details

Defined in Data.Aeson.Types.ToJSON

ToJSON UTCTime
Instance details

Defined in Data.Aeson.Types.ToJSON

ToJSON Text
Instance details

Defined in Data.Aeson.Types.ToJSON

ToJSON Value
Instance details

Defined in Data.Aeson.Types.ToJSON

ToJSON DotNetTime
Instance details

Defined in Data.Aeson.Types.ToJSON

ToJSON Key
Instance details

Defined in Data.Aeson.Types.ToJSON

ToJSON Text
Instance details

Defined in Data.Aeson.Types.ToJSON

ToJSON Number
Instance details

Defined in Data.Aeson.Types.ToJSON

ToJSON Void
Instance details

Defined in Data.Aeson.Types.ToJSON

ToJSON Version
Instance details

Defined in Data.Aeson.Types.ToJSON

ToJSON CTime
Instance details

Defined in Data.Aeson.Types.ToJSON

ToJSON IntSet
Instance details

Defined in Data.Aeson.Types.ToJSON

ToJSON ShortText

Since: aeson-2.0.2.0

Instance details

Defined in Data.Aeson.Types.ToJSON

ToJSON ZonedTime
Instance details

Defined in Data.Aeson.Types.ToJSON

ToJSON LocalTime
Instance details

Defined in Data.Aeson.Types.ToJSON

ToJSON TimeOfDay
Instance details

Defined in Data.Aeson.Types.ToJSON

ToJSON CalendarDiffTime
Instance details

Defined in Data.Aeson.Types.ToJSON

ToJSON SystemTime

Encoded as number

Instance details

Defined in Data.Aeson.Types.ToJSON

ToJSON NominalDiffTime
Instance details

Defined in Data.Aeson.Types.ToJSON

ToJSON DiffTime
Instance details

Defined in Data.Aeson.Types.ToJSON

ToJSON DayOfWeek
Instance details

Defined in Data.Aeson.Types.ToJSON

ToJSON Day
Instance details

Defined in Data.Aeson.Types.ToJSON

ToJSON CalendarDiffDays
Instance details

Defined in Data.Aeson.Types.ToJSON

ToJSON QuarterOfYear
Instance details

Defined in Data.Aeson.Types.ToJSON

ToJSON Quarter
Instance details

Defined in Data.Aeson.Types.ToJSON

ToJSON Month
Instance details

Defined in Data.Aeson.Types.ToJSON

ToJSON UUID
Instance details

Defined in Data.Aeson.Types.ToJSON

ToJSON a => ToJSON [a]
Instance details

Defined in Data.Aeson.Types.ToJSON

ToJSON a => ToJSON ( Maybe a)
Instance details

Defined in Data.Aeson.Types.ToJSON

( ToJSON a, Integral a) => ToJSON ( Ratio a)
Instance details

Defined in Data.Aeson.Types.ToJSON

ToJSON a => ToJSON ( Solo a)

Since: aeson-2.0.2.0

Instance details

Defined in Data.Aeson.Types.ToJSON

ToJSON v => ToJSON ( KeyMap v)
Instance details

Defined in Data.Aeson.Types.ToJSON

ToJSON a => ToJSON ( Min a)
Instance details

Defined in Data.Aeson.Types.ToJSON

ToJSON a => ToJSON ( Max a)
Instance details

Defined in Data.Aeson.Types.ToJSON

ToJSON a => ToJSON ( First a)
Instance details

Defined in Data.Aeson.Types.ToJSON

ToJSON a => ToJSON ( Last a)
Instance details

Defined in Data.Aeson.Types.ToJSON

ToJSON a => ToJSON ( WrappedMonoid a)
Instance details

Defined in Data.Aeson.Types.ToJSON

ToJSON a => ToJSON ( Option a)
Instance details

Defined in Data.Aeson.Types.ToJSON

ToJSON a => ToJSON ( Identity a)
Instance details

Defined in Data.Aeson.Types.ToJSON

ToJSON a => ToJSON ( First a)
Instance details

Defined in Data.Aeson.Types.ToJSON

ToJSON a => ToJSON ( Last a)
Instance details

Defined in Data.Aeson.Types.ToJSON

ToJSON a => ToJSON ( Dual a)
Instance details

Defined in Data.Aeson.Types.ToJSON

ToJSON a => ToJSON ( NonEmpty a)
Instance details

Defined in Data.Aeson.Types.ToJSON

ToJSON a => ToJSON ( IntMap a)
Instance details

Defined in Data.Aeson.Types.ToJSON

ToJSON v => ToJSON ( Tree v)
Instance details

Defined in Data.Aeson.Types.ToJSON

ToJSON a => ToJSON ( Seq a)
Instance details

Defined in Data.Aeson.Types.ToJSON

ToJSON a => ToJSON ( Set a)
Instance details

Defined in Data.Aeson.Types.ToJSON

ToJSON1 f => ToJSON ( Fix f)

Since: aeson-1.5.3.0

Instance details

Defined in Data.Aeson.Types.ToJSON

( ToJSON1 f, Functor f) => ToJSON ( Mu f)

Since: aeson-1.5.3.0

Instance details

Defined in Data.Aeson.Types.ToJSON

( ToJSON1 f, Functor f) => ToJSON ( Nu f)

Since: aeson-1.5.3.0

Instance details

Defined in Data.Aeson.Types.ToJSON

ToJSON a => ToJSON ( DNonEmpty a)

Since: aeson-1.5.3.0

Instance details

Defined in Data.Aeson.Types.ToJSON

ToJSON a => ToJSON ( DList a)
Instance details

Defined in Data.Aeson.Types.ToJSON

( Prim a, ToJSON a) => ToJSON ( PrimArray a)
Instance details

Defined in Data.Aeson.Types.ToJSON

ToJSON a => ToJSON ( SmallArray a)
Instance details

Defined in Data.Aeson.Types.ToJSON

ToJSON a => ToJSON ( Array a)
Instance details

Defined in Data.Aeson.Types.ToJSON

ToJSON a => ToJSON ( Maybe a)

Since: aeson-1.5.3.0

Instance details

Defined in Data.Aeson.Types.ToJSON

ToJSON a => ToJSON ( HashSet a)
Instance details

Defined in Data.Aeson.Types.ToJSON

( Vector Vector a, ToJSON a) => ToJSON ( Vector a)
Instance details

Defined in Data.Aeson.Types.ToJSON

( Storable a, ToJSON a) => ToJSON ( Vector a)
Instance details

Defined in Data.Aeson.Types.ToJSON

( Prim a, ToJSON a) => ToJSON ( Vector a)
Instance details

Defined in Data.Aeson.Types.ToJSON

ToJSON a => ToJSON ( Vector a)
Instance details

Defined in Data.Aeson.Types.ToJSON

( ToJSON a, ToJSON b) => ToJSON ( Either a b)
Instance details

Defined in Data.Aeson.Types.ToJSON

( ToJSON a, ToJSON b) => ToJSON (a, b)
Instance details

Defined in Data.Aeson.Types.ToJSON

( ToJSON v, ToJSONKey k) => ToJSON ( Map k v)
Instance details

Defined in Data.Aeson.Types.ToJSON

( ToJSON v, ToJSONKey k) => ToJSON ( HashMap k v)
Instance details

Defined in Data.Aeson.Types.ToJSON

HasResolution a => ToJSON ( Fixed a)
Instance details

Defined in Data.Aeson.Types.ToJSON

ToJSON ( Proxy a)
Instance details

Defined in Data.Aeson.Types.ToJSON

( ToJSON a, ToJSON b) => ToJSON ( These a b)

Since: aeson-1.5.1.0

Instance details

Defined in Data.Aeson.Types.ToJSON

( ToJSON a, ToJSON b) => ToJSON ( Pair a b)

Since: aeson-1.5.3.0

Instance details

Defined in Data.Aeson.Types.ToJSON

( ToJSON a, ToJSON b) => ToJSON ( These a b)

Since: aeson-1.5.3.0

Instance details

Defined in Data.Aeson.Types.ToJSON

( ToJSON a, ToJSON b) => ToJSON ( Either a b)

Since: aeson-1.5.3.0

Instance details

Defined in Data.Aeson.Types.ToJSON

( ToJSON a, ToJSON b, ToJSON c) => ToJSON (a, b, c)
Instance details

Defined in Data.Aeson.Types.ToJSON

ToJSON a => ToJSON ( Const a b)
Instance details

Defined in Data.Aeson.Types.ToJSON

ToJSON b => ToJSON ( Tagged a b)
Instance details

Defined in Data.Aeson.Types.ToJSON

( ToJSON1 f, ToJSON1 g, ToJSON a) => ToJSON ( These1 f g a)

Since: aeson-1.5.1.0

Instance details

Defined in Data.Aeson.Types.ToJSON

( AesonOptions t, Generic a, GToJSON Zero ( Rep a), GToEncoding Zero ( Rep a)) => ToJSON ( CustomJSON t a) Source #
Instance details

Defined in Deriving.Aeson

( ToJSON a, ToJSON b, ToJSON c, ToJSON d) => ToJSON (a, b, c, d)
Instance details

Defined in Data.Aeson.Types.ToJSON

( ToJSON1 f, ToJSON1 g, ToJSON a) => ToJSON ( Product f g a)
Instance details

Defined in Data.Aeson.Types.ToJSON

( ToJSON1 f, ToJSON1 g, ToJSON a) => ToJSON ( Sum f g a)
Instance details

Defined in Data.Aeson.Types.ToJSON

( ToJSON a, ToJSON b, ToJSON c, ToJSON d, ToJSON e) => ToJSON (a, b, c, d, e)
Instance details

Defined in Data.Aeson.Types.ToJSON

Methods

toJSON :: (a, b, c, d, e) -> Value Source #

toEncoding :: (a, b, c, d, e) -> Encoding Source #

toJSONList :: [(a, b, c, d, e)] -> Value Source #

toEncodingList :: [(a, b, c, d, e)] -> Encoding Source #

( ToJSON1 f, ToJSON1 g, ToJSON a) => ToJSON ( Compose f g a)
Instance details

Defined in Data.Aeson.Types.ToJSON

( ToJSON a, ToJSON b, ToJSON c, ToJSON d, ToJSON e, ToJSON f) => ToJSON (a, b, c, d, e, f)
Instance details

Defined in Data.Aeson.Types.ToJSON

Methods

toJSON :: (a, b, c, d, e, f) -> Value Source #

toEncoding :: (a, b, c, d, e, f) -> Encoding Source #

toJSONList :: [(a, b, c, d, e, f)] -> Value Source #

toEncodingList :: [(a, b, c, d, e, f)] -> Encoding Source #

( ToJSON a, ToJSON b, ToJSON c, ToJSON d, ToJSON e, ToJSON f, ToJSON g) => ToJSON (a, b, c, d, e, f, g)
Instance details

Defined in Data.Aeson.Types.ToJSON

Methods

toJSON :: (a, b, c, d, e, f, g) -> Value Source #

toEncoding :: (a, b, c, d, e, f, g) -> Encoding Source #

toJSONList :: [(a, b, c, d, e, f, g)] -> Value Source #

toEncodingList :: [(a, b, c, d, e, f, g)] -> Encoding Source #

( ToJSON a, ToJSON b, ToJSON c, ToJSON d, ToJSON e, ToJSON f, ToJSON g, ToJSON h) => ToJSON (a, b, c, d, e, f, g, h)
Instance details

Defined in Data.Aeson.Types.ToJSON

Methods

toJSON :: (a, b, c, d, e, f, g, h) -> Value Source #

toEncoding :: (a, b, c, d, e, f, g, h) -> Encoding Source #

toJSONList :: [(a, b, c, d, e, f, g, h)] -> Value Source #

toEncodingList :: [(a, b, c, d, e, f, g, h)] -> Encoding Source #

( ToJSON a, ToJSON b, ToJSON c, ToJSON d, ToJSON e, ToJSON f, ToJSON g, ToJSON h, ToJSON i) => ToJSON (a, b, c, d, e, f, g, h, i)
Instance details

Defined in Data.Aeson.Types.ToJSON

Methods

toJSON :: (a, b, c, d, e, f, g, h, i) -> Value Source #

toEncoding :: (a, b, c, d, e, f, g, h, i) -> Encoding Source #

toJSONList :: [(a, b, c, d, e, f, g, h, i)] -> Value Source #

toEncodingList :: [(a, b, c, d, e, f, g, h, i)] -> Encoding Source #

( ToJSON a, ToJSON b, ToJSON c, ToJSON d, ToJSON e, ToJSON f, ToJSON g, ToJSON h, ToJSON i, ToJSON j) => ToJSON (a, b, c, d, e, f, g, h, i, j)
Instance details

Defined in Data.Aeson.Types.ToJSON

Methods

toJSON :: (a, b, c, d, e, f, g, h, i, j) -> Value Source #

toEncoding :: (a, b, c, d, e, f, g, h, i, j) -> Encoding Source #

toJSONList :: [(a, b, c, d, e, f, g, h, i, j)] -> Value Source #

toEncodingList :: [(a, b, c, d, e, f, g, h, i, j)] -> Encoding Source #

( ToJSON a, ToJSON b, ToJSON c, ToJSON d, ToJSON e, ToJSON f, ToJSON g, ToJSON h, ToJSON i, ToJSON j, ToJSON k) => ToJSON (a, b, c, d, e, f, g, h, i, j, k)
Instance details

Defined in Data.Aeson.Types.ToJSON

Methods

toJSON :: (a, b, c, d, e, f, g, h, i, j, k) -> Value Source #

toEncoding :: (a, b, c, d, e, f, g, h, i, j, k) -> Encoding Source #

toJSONList :: [(a, b, c, d, e, f, g, h, i, j, k)] -> Value Source #

toEncodingList :: [(a, b, c, d, e, f, g, h, i, j, k)] -> Encoding Source #

( ToJSON a, ToJSON b, ToJSON c, ToJSON d, ToJSON e, ToJSON f, ToJSON g, ToJSON h, ToJSON i, ToJSON j, ToJSON k, ToJSON l) => ToJSON (a, b, c, d, e, f, g, h, i, j, k, l)
Instance details

Defined in Data.Aeson.Types.ToJSON

Methods

toJSON :: (a, b, c, d, e, f, g, h, i, j, k, l) -> Value Source #

toEncoding :: (a, b, c, d, e, f, g, h, i, j, k, l) -> Encoding Source #

toJSONList :: [(a, b, c, d, e, f, g, h, i, j, k, l)] -> Value Source #

toEncodingList :: [(a, b, c, d, e, f, g, h, i, j, k, l)] -> Encoding Source #

( ToJSON a, ToJSON b, ToJSON c, ToJSON d, ToJSON e, ToJSON f, ToJSON g, ToJSON h, ToJSON i, ToJSON j, ToJSON k, ToJSON l, ToJSON m) => ToJSON (a, b, c, d, e, f, g, h, i, j, k, l, m)
Instance details

Defined in Data.Aeson.Types.ToJSON

Methods

toJSON :: (a, b, c, d, e, f, g, h, i, j, k, l, m) -> Value Source #

toEncoding :: (a, b, c, d, e, f, g, h, i, j, k, l, m) -> Encoding Source #

toJSONList :: [(a, b, c, d, e, f, g, h, i, j, k, l, m)] -> Value Source #

toEncodingList :: [(a, b, c, d, e, f, g, h, i, j, k, l, m)] -> Encoding Source #

( ToJSON a, ToJSON b, ToJSON c, ToJSON d, ToJSON e, ToJSON f, ToJSON g, ToJSON h, ToJSON i, ToJSON j, ToJSON k, ToJSON l, ToJSON m, ToJSON n) => ToJSON (a, b, c, d, e, f, g, h, i, j, k, l, m, n)
Instance details

Defined in Data.Aeson.Types.ToJSON

Methods

toJSON :: (a, b, c, d, e, f, g, h, i, j, k, l, m, n) -> Value Source #

toEncoding :: (a, b, c, d, e, f, g, h, i, j, k, l, m, n) -> Encoding Source #

toJSONList :: [(a, b, c, d, e, f, g, h, i, j, k, l, m, n)] -> Value Source #

toEncodingList :: [(a, b, c, d, e, f, g, h, i, j, k, l, m, n)] -> Encoding Source #

( ToJSON a, ToJSON b, ToJSON c, ToJSON d, ToJSON e, ToJSON f, ToJSON g, ToJSON h, ToJSON i, ToJSON j, ToJSON k, ToJSON l, ToJSON m, ToJSON n, ToJSON o) => ToJSON (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o)
Instance details

Defined in Data.Aeson.Types.ToJSON

Methods

toJSON :: (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o) -> Value Source #

toEncoding :: (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o) -> Encoding Source #

toJSONList :: [(a, b, c, d, e, f, g, h, i, j, k, l, m, n, o)] -> Value Source #

toEncodingList :: [(a, b, c, d, e, f, g, h, i, j, k, l, m, n, o)] -> Encoding Source #

class Generic a Source #

Representable types of kind * . This class is derivable in GHC with the DeriveGeneric flag on.

A Generic instance must satisfy the following laws:

from . to ≡ id
to . from ≡ id

Minimal complete definition

from , to

Instances

Instances details
Generic Bool

Since: base-4.6.0.0

Instance details

Defined in GHC.Generics

Associated Types

type Rep Bool :: Type -> Type Source #

Generic Ordering

Since: base-4.6.0.0

Instance details

Defined in GHC.Generics

Generic ()

Since: base-4.6.0.0

Instance details

Defined in GHC.Generics

Associated Types

type Rep () :: Type -> Type Source #

Methods

from :: () -> Rep () x Source #

to :: Rep () x -> () Source #

Generic Value
Instance details

Defined in Data.Aeson.Types.Internal

Generic ExitCode
Instance details

Defined in GHC.IO.Exception

Generic Fixity

Since: base-4.7.0.0

Instance details

Defined in GHC.Generics

Generic Associativity

Since: base-4.7.0.0

Instance details

Defined in GHC.Generics

Generic SourceUnpackedness

Since: base-4.9.0.0

Instance details

Defined in GHC.Generics

Generic SourceStrictness

Since: base-4.9.0.0

Instance details

Defined in GHC.Generics

Generic DecidedStrictness

Since: base-4.9.0.0

Instance details

Defined in GHC.Generics

Generic [a]

Since: base-4.6.0.0

Instance details

Defined in GHC.Generics

Associated Types

type Rep [a] :: Type -> Type Source #

Methods

from :: [a] -> Rep [a] x Source #

to :: Rep [a] x -> [a] Source #

Generic ( Maybe a)

Since: base-4.6.0.0

Instance details

Defined in GHC.Generics

Associated Types

type Rep ( Maybe a) :: Type -> Type Source #

Generic ( Par1 p)

Since: base-4.7.0.0

Instance details

Defined in GHC.Generics

Associated Types

type Rep ( Par1 p) :: Type -> Type Source #

Generic ( Down a)

Since: base-4.12.0.0

Instance details

Defined in GHC.Generics

Associated Types

type Rep ( Down a) :: Type -> Type Source #

Generic ( NonEmpty a)

Since: base-4.6.0.0

Instance details

Defined in GHC.Generics

Associated Types

type Rep ( NonEmpty a) :: Type -> Type Source #

Generic ( Either a b)

Since: base-4.6.0.0

Instance details

Defined in GHC.Generics

Associated Types

type Rep ( Either a b) :: Type -> Type Source #

Generic ( V1 p)

Since: base-4.9.0.0

Instance details

Defined in GHC.Generics

Associated Types

type Rep ( V1 p) :: Type -> Type Source #

Generic ( U1 p)

Since: base-4.7.0.0

Instance details

Defined in GHC.Generics

Associated Types

type Rep ( U1 p) :: Type -> Type Source #

Generic (a, b)

Since: base-4.6.0.0

Instance details

Defined in GHC.Generics

Associated Types

type Rep (a, b) :: Type -> Type Source #

Methods

from :: (a, b) -> Rep (a, b) x Source #

to :: Rep (a, b) x -> (a, b) Source #

Generic ( Proxy t)

Since: base-4.6.0.0

Instance details

Defined in GHC.Generics

Associated Types

type Rep ( Proxy t) :: Type -> Type Source #

Generic ( Rec1 f p)

Since: base-4.7.0.0

Instance details

Defined in GHC.Generics

Associated Types

type Rep ( Rec1 f p) :: Type -> Type Source #

Generic ( URec ( Ptr ()) p)

Since: base-4.9.0.0

Instance details

Defined in GHC.Generics

Associated Types

type Rep ( URec ( Ptr ()) p) :: Type -> Type Source #

Generic ( URec Char p)

Since: base-4.9.0.0

Instance details

Defined in GHC.Generics

Associated Types

type Rep ( URec Char p) :: Type -> Type Source #

Generic ( URec Double p)

Since: base-4.9.0.0

Instance details

Defined in GHC.Generics

Generic ( URec Float p)
Instance details

Defined in GHC.Generics

Generic ( URec Int p)

Since: base-4.9.0.0

Instance details

Defined in GHC.Generics

Associated Types

type Rep ( URec Int p) :: Type -> Type Source #

Generic ( URec Word p)

Since: base-4.9.0.0

Instance details

Defined in GHC.Generics

Associated Types

type Rep ( URec Word p) :: Type -> Type Source #

Generic (a, b, c)

Since: base-4.6.0.0

Instance details

Defined in GHC.Generics

Associated Types

type Rep (a, b, c) :: Type -> Type Source #

Methods

from :: (a, b, c) -> Rep (a, b, c) x Source #

to :: Rep (a, b, c) x -> (a, b, c) Source #

Generic ( K1 i c p)

Since: base-4.7.0.0

Instance details

Defined in GHC.Generics

Associated Types

type Rep ( K1 i c p) :: Type -> Type Source #

Methods

from :: K1 i c p -> Rep ( K1 i c p) x Source #

to :: Rep ( K1 i c p) x -> K1 i c p Source #

Generic ((f :+: g) p)

Since: base-4.7.0.0

Instance details

Defined in GHC.Generics

Associated Types

type Rep ((f :+: g) p) :: Type -> Type Source #

Methods

from :: (f :+: g) p -> Rep ((f :+: g) p) x Source #

to :: Rep ((f :+: g) p) x -> (f :+: g) p Source #

Generic ((f :*: g) p)

Since: base-4.7.0.0

Instance details

Defined in GHC.Generics

Associated Types

type Rep ((f :*: g) p) :: Type -> Type Source #

Methods

from :: (f :*: g) p -> Rep ((f :*: g) p) x Source #

to :: Rep ((f :*: g) p) x -> (f :*: g) p Source #

Generic (a, b, c, d)

Since: base-4.6.0.0

Instance details

Defined in GHC.Generics

Associated Types

type Rep (a, b, c, d) :: Type -> Type Source #

Methods

from :: (a, b, c, d) -> Rep (a, b, c, d) x Source #

to :: Rep (a, b, c, d) x -> (a, b, c, d) Source #

Generic ( M1 i c f p)

Since: base-4.7.0.0

Instance details

Defined in GHC.Generics

Associated Types

type Rep ( M1 i c f p) :: Type -> Type Source #

Methods

from :: M1 i c f p -> Rep ( M1 i c f p) x Source #

to :: Rep ( M1 i c f p) x -> M1 i c f p Source #

Generic ((f :.: g) p)

Since: base-4.7.0.0

Instance details

Defined in GHC.Generics

Associated Types

type Rep ((f :.: g) p) :: Type -> Type Source #

Methods

from :: (f :.: g) p -> Rep ((f :.: g) p) x Source #

to :: Rep ((f :.: g) p) x -> (f :.: g) p Source #

Generic (a, b, c, d, e)

Since: base-4.6.0.0

Instance details

Defined in GHC.Generics

Associated Types

type Rep (a, b, c, d, e) :: Type -> Type Source #

Methods

from :: (a, b, c, d, e) -> Rep (a, b, c, d, e) x Source #

to :: Rep (a, b, c, d, e) x -> (a, b, c, d, e) Source #

Generic (a, b, c, d, e, f)

Since: base-4.6.0.0

Instance details

Defined in GHC.Generics

Associated Types

type Rep (a, b, c, d, e, f) :: Type -> Type Source #

Methods

from :: (a, b, c, d, e, f) -> Rep (a, b, c, d, e, f) x Source #

to :: Rep (a, b, c, d, e, f) x -> (a, b, c, d, e, f) Source #

Generic (a, b, c, d, e, f, g)

Since: base-4.6.0.0

Instance details

Defined in GHC.Generics

Associated Types

type Rep (a, b, c, d, e, f, g) :: Type -> Type Source #

Methods

from :: (a, b, c, d, e, f, g) -> Rep (a, b, c, d, e, f, g) x Source #

to :: Rep (a, b, c, d, e, f, g) x -> (a, b, c, d, e, f, g) Source #