aeson-injector-2.0.0.0: Injecting fields into aeson values
Copyright(c) Anton Gushcha 2016
LicenseMIT
Maintainerncrashed@gmail.com
Stabilityexperimental
PortabilityPortable
Safe HaskellSafe-Inferred
LanguageHaskell2010

Data.Aeson.Unit

Description

Common problem in REST interfaces when you need to return nothing as result, usage of () will produce `[]` JSON. That causes problems in some JSON parsers in other languages.

So, Unit serialises into empty JSON object:

>>> encode Unit
"{}"
Synopsis

Documentation

data Unit Source #

Data type that serialise into empty object in aeson

>>> encode Unit
"{}"
>>> encode $ toSchema (Proxy :: Proxy Unit)
"{\"type\":\"object\"}"

Also the FromJSON instance is just `pure Unit`, so it never fails.

Constructors

Unit 

Instances

Instances details
FromJSON Unit Source #

Always a success parse

Instance details

Defined in Data.Aeson.Unit

ToJSON Unit Source # 
Instance details

Defined in Data.Aeson.Unit

Bounded Unit Source # 
Instance details

Defined in Data.Aeson.Unit

Enum Unit Source # 
Instance details

Defined in Data.Aeson.Unit

Methods

succ :: Unit -> Unit #

pred :: Unit -> Unit #

toEnum :: Int -> Unit #

fromEnum :: Unit -> Int #

enumFrom :: Unit -> [Unit] #

enumFromThen :: Unit -> Unit -> [Unit] #

enumFromTo :: Unit -> Unit -> [Unit] #

enumFromThenTo :: Unit -> Unit -> Unit -> [Unit] #

Generic Unit Source # 
Instance details

Defined in Data.Aeson.Unit

Associated Types

type Rep Unit :: Type -> Type #

Methods

from :: Unit -> Rep Unit x #

to :: Rep Unit x -> Unit #

Read Unit Source # 
Instance details

Defined in Data.Aeson.Unit

Show Unit Source # 
Instance details

Defined in Data.Aeson.Unit

Methods

showsPrec :: Int -> Unit -> ShowS #

show :: Unit -> String #

showList :: [Unit] -> ShowS #

Eq Unit Source # 
Instance details

Defined in Data.Aeson.Unit

Methods

(==) :: Unit -> Unit -> Bool #

(/=) :: Unit -> Unit -> Bool #

ToSchema Unit Source # 
Instance details

Defined in Data.Aeson.Unit

type Rep Unit Source # 
Instance details

Defined in Data.Aeson.Unit

type Rep Unit = D1 ('MetaData "Unit" "Data.Aeson.Unit" "aeson-injector-2.0.0.0-402vwUZjeHYLbMFCBckd6W" 'False) (C1 ('MetaCons "Unit" 'PrefixI 'False) (U1 :: Type -> Type))