aeson-injector-1.1.3.0: Injecting fields into aeson values

Copyright(c) Anton Gushcha 2016
LicenseMIT
Maintainerncrashed@gmail.com
Stabilityexperimental
PortabilityPortable
Safe HaskellNone
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
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] #

Eq Unit Source # 
Instance details

Defined in Data.Aeson.Unit

Methods

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

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

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 #

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 #

ToJSON Unit Source # 
Instance details

Defined in Data.Aeson.Unit

FromJSON Unit Source #

Always a success parse

Instance details

Defined in Data.Aeson.Unit

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-1.1.3.0-6MY5WVAvsf2AfVianu6uUb" False) (C1 (MetaCons "Unit" PrefixI False) (U1 :: Type -> Type))